Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
brendan_w
Frequent Visitor

What if Parameter - altering report date error?

Hi,

 

So I have the following DAX which works perfectly:

Daily Tonnage = CALCULATE( [Tonne Food Received], 'Monthly Data'[Date] > TODAY() - 1)

 

This calculates the tonnage received on today's date. I now set up a what if parameter called Days Previous. This will hopefully allow me to change the day the formula acts on interactively like so:

 

Daily Tonnage = CALCULATE( [Tonne Food Received], 'Monthly Data'[Date] > TODAY() - 'Days Previous'[Days Previous Value] - 1)

 

however this gives the error :

 

Error Message:
Something's wrong with one or more fields: (KPI Measures) Todays Donation: A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.,

 

TODAY() - 1 and TODAY() - 'Days Previous'[Days Previous Value] - 1 are both scalers, so not sure why this error is occuring. Could anyone provide any help on a potential workaround or shed light on an error on my side please?

 

Many thanks in advance!

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

=CALCULATE( [Tonne Food Received], FILTER('Monthly Data','Monthly Data'[Date] > TODAY() - 'Days Previous'[Days Previous Value] - 1))

 

Does this work?

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

=CALCULATE( [Tonne Food Received], FILTER('Monthly Data','Monthly Data'[Date] > TODAY() - 'Days Previous'[Days Previous Value] - 1))

 

Does this work?

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks Ashish, that did the job! Out of curiosity, what is different between the Filter function and the filter argument within Calculate? I've a vague recollection of reading somewhere that they result in the same functionality. Clearly this is not the case or else the code for Calculate has yet to be updated.

Hi,

 

You are welcome.  The reason we need to use the FILTER() function is that yours is a case of rich filtering i.e. comparing a column to a measure.  The measure being TODAY().


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.