Sum between selected date values

Hey all,

I want to get sum of [Today's Total] from another table called milk production which contains cow number (ref ) so does this table. Now, I want to get the sum of those values from that table to be calculated in this tables form i.e. Lactation Details which asks for lactation start and end days this will then be used to find the total milk produced by the cow selected in the particular lactation. I used the expression below but it returns 0 whenever the dates are selected

SUM(SELECT(Milk Production[Today's total],AND(
[Cow Number]=[_THISROW].[Cow Number],
DATE(Milk Production[Date])>[Lactation Start Date],
DATE(Milk Production[Date])<[Lactation End Date])
)
)

Solved Solved
0 1 91
1 ACCEPTED SOLUTION

To have the expression syntactically correct at least, please try the following expression

SUM(SELECT(Milk Production[Today's total],AND(
[Cow Number]=[_THISROW].[Cow Number],
[Date]>[Lactation Start Date],
[Date])<[Lactation End Date])
)
)

This may need tweak, if the understanding based on description so far is incorrect.  You may need to furnish more details in that case. The expression assumes , the [Date] column in the "Milk Production" table is a date type column.  

There could be possibly more economical ways of running the SUM() function on a smaller number of records by using slice etc. depending upon your app configuration.

View solution in original post

1 REPLY 1

To have the expression syntactically correct at least, please try the following expression

SUM(SELECT(Milk Production[Today's total],AND(
[Cow Number]=[_THISROW].[Cow Number],
[Date]>[Lactation Start Date],
[Date])<[Lactation End Date])
)
)

This may need tweak, if the understanding based on description so far is incorrect.  You may need to furnish more details in that case. The expression assumes , the [Date] column in the "Milk Production" table is a date type column.  

There could be possibly more economical ways of running the SUM() function on a smaller number of records by using slice etc. depending upon your app configuration.

Top Labels in this Space