I have a table in a report which shows the number of open cases by age group at the end of each month, this uses an age group table and a dates table which are separate from the main data table (called Child in the formula below). It seems to work except for the totals in the table which are behaving very strangely I have looked for solutions here and kind of understand why totals don't work in power bi tables because of contexts but can't understand why I am getting such low figures here and what they are based on.
My formula is this:
Number Children by Age Group =
VAR AgeMin = SELECTEDVALUE ( 'Age Group Table'[AgeMin] )
VAR AgeMax = SELECTEDVALUE ( 'Age Group Table'[AgeMax] )
RETURN
CALCULATE (
DISTINCTCOUNT ( 'Child'[Person ID] ),
FILTER (
'Child',
'Child'[Start_Date] <= MAX ( Dates[Date] )
&& ('Child'[End_Date] >= MAX ( Dates[Date] ) || ISBLANK ( 'Child'[End_Date] ) )
&& FLOOR ( DATEDIFF ( 'Child'[Date of Birth], MAX ( Dates[Date] ), DAY ) / 365.25, 1 ) >= AgeMin
&& FLOOR ( DATEDIFF ( 'Child'[Date of Birth], MAX ( Dates[Date] ), DAY ) / 365.25, 1 ) <= AgeMax
)
)
and the results I am getting in my table are:
If I put a sumx around the formula the totals go up to around 180, higher but still far too low I don't have to have the totals in the table but I would like to be able to understand what is going on to increase my knowledge of dax formulae
MIN
andMAX
rather thanSELECTEDVALUE
twice when defining your variables change the total? – Alexis Olson