Forum Discussion
Display data for dates relative to date selected in table
Anonymous Thank you so much for the clarification, I understood that better than I did the video. I've adjusted the calculations to be:
Now I'm getting the error:
A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.
Do you think this error is to do with the SelPeriod variable? I used this approach (remove date filters, keep selperiod filter) in another BI report and it worked correctly. The only difference between the two is the addition of the AdjMonth variable in this report. Do I need to combine the AdjMonth and SelPeriod variables into one?
Thanks so much for your help!
Anonymous again this is very difficult to debug without sample data or properly formatted code, but the Revenue variable jumps out to me as not looking quite right. You're multiplying a Filter argument by -1, when I think you're meaning to multiply the result of the CALCULATE statement by -1.
VAR Revenue = CALCULATE(SUM(Transactions[Net Change]), FILTER(Transactions, Transactions[Source]="Actual"), FILTER(Mapping, Mapping[PLcalc] = "Revenue")*-1, REMOVEFILTERS('Date'), KEEPFILTERS(SelPeriod), USERELATIONSHIP('Date'[Date], 'Calendar'[Date]))
Putting this in the proper format using https://www.daxformatter.com/ makes this more clear:
VAR Revenue =
CALCULATE (
SUM ( Transactions[Net Change] ),
FILTER ( Transactions, Transactions[Source] = "Actual" ),
FILTER ( Mapping, Mapping[PLcalc] = "Revenue" ) * -1,
REMOVEFILTERS ( 'Date' ),
KEEPFILTERS ( SelPeriod ),
USERELATIONSHIP ( 'Date'[Date], 'Calendar'[Date] )
)