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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.