Forum Discussion

MCornish's avatar
MCornish
Responsive Resident
5 years ago

Calculation Group being Weird When Filtered

Hi All

 

I'm messing around with calculation groups and found something weird happening when I filter my dimension.

 

So I have calculation that do YTD, MTD, WTD etc and they all work fine. See below, I've changed my measure to return 1 if its not blank and 0 if it is for obvious reasons

 

Unfiltered

You can see some codes have a 1 others a 0 and the total is 1 (with real numbers this is accurate)

 

If I remove any code (blank in this case) everything is 0 except for the total

 

Filtered

 

MTD and the other do not have this problem. DAX below

 

YTD - (Not working)

VAR Year = CALCULATE( SELECTEDVALUE( Dates[Year] ), Dates[IsTodayFlag] = TRUE() ) 
VAR
ReturnValue = CALCULATE( SELECTEDMEASURE(), Dates[Year] = Year, Dates[Is Part Of Current Year?] = TRUE() )

RETURN
IF
( ReturnValue = BLANK(), 0, 1 )

 

MTD - (Working)

VAR Year = CALCULATE( SELECTEDVALUE( Dates[Year] ), Dates[IsTodayFlag] = TRUE() ) 
VAR
CDate = CALCULATE( SELECTEDVALUE( Dates[Date]) , Dates[IsTodayFlag] = TRUE() )
VAR
CMonth = CALCULATE( SELECTEDVALUE( Dates[Month] ), Dates[Date] = CDate )
VAR
ReturnValue = CALCULATE( SELECTEDMEASURE(), Dates[Year] = Year, Dates[Month] = CMonth, Dates[Is Part Of Current Year?] = TRUE() )

RETURN
IF
( ReturnValue = BLANK(), 0, 1 )

 

I know the measures can be written better, i.e. using DATESYTD etc, but like I said, im just playing at the moment 

2 Replies