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
BrentonBarnes
Regular Visitor

Dynamic filter using Source.Name

I have a production order dataset with past and future dates. I want to calculate the sum of delivered, and sum of ordered quantity for ONLY the dates equal to or prior to the report run date (I want to avoid summing open production orders that are not yet due). I am using a file naming convention with date as integer as the first 8 digits. Example: 20190815_ProductionOrd.xlsx

I created a column with the this formula: Report Date = LEFT('ProdOrd'[Source.Name],8) to return 20190815 on all rows.

I also have a date table (relationship built) with "date as integer" as one of the columns

 

I'm having trouble writing a formula that will use the MAX('Report Date') in the filter expression. I can't get CALCULATE or FILTER to accept the numeric value MAX('Report Date') which would be 20190815. I keep getting the error - A function 'MAX' has been used in a True/False expression that is used as a table filter expression

 

FY19 Act = CALCULATE(SUM('ProdOrd'[Delivered quantity (GMEIN)]),'Date'[Date As Integer]<=MAX('ProdOrd'[Report Date]))

 

Capture.PNG

1 REPLY 1
TeigeGao
Solution Sage
Solution Sage

Hi @BrentonBarnes ,

In your scenario, you can set a variable to store the result of MAX('Report Date'), then use the variable in the DAX query.

Best Regards,

Teige

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.