Forum Discussion
Power Automate Monthly/Most Recent Sales Data in Email
You want to filter your data in the DAX query. Paste that query from the viz into DAX Studio, clean it up so it is the core SUMMARIZECOLUMNS() query.
You can obtain the MAX (latest) date from that query using MAXX(the query, [the date field]) and assign that to a variable, then wrap the entire SUMMARIZECOLUMNS() in a CALCULATETABLE() filtering for that date. You can also use TREATAS() inthe SUMMARIZECOLUMNS() filter conditions, but there will be a neglible performance diff.
You could post your DAX query here for assistance, or you need to head to the Power Automate forum if you want to filter your file using PA, but that will return a larger dataset to be filtered.
As an example, from DAX.DO - this is a query on sales but only for the last Due Date in the model.
EVALUATE
VAR varMaxDate =
MAX ( sales[Due Date] )
RETURN
SUMMARIZECOLUMNS (
Customer[Customer Type],
'Product'[Brand],
Sales[Due Date],
TREATAS ( { varMaxDate }, Sales[Due Date] ),
"@Sales", [Sales Amount]
)
You can play with that query here. https://dax.do/TRQwyrLLqlKNGx/
The TREATAS line is taking that max date and filtering the entire table. You can use a range of dates too.
EVALUATE
VAR varMaxDates =
TOPN(10, VALUES(Sales[Due Date]), Sales[Due Date], DESC)
RETURN
SUMMARIZECOLUMNS (
Customer[Customer Type],
'Product'[Brand],
Sales[Due Date],
TREATAS ( varMaxDates, Sales[Due Date] ),
"@Sales", [Sales Amount]
)
That keeps the last 10 dates in the query.