Hi all,
I need to sum up sales for the latest date of a month. I have tried calculate(sales,max(date)) but DAX doesn't like that. Any suggestions/thoughts? Thanks,
Dan
You can use an expression like
= CALCULATE( [Sales], LASTDATE('Date'[Date]) )
to get sales on the max date in the current filter context, e.g. in March it would give you sales on 31 March.
If you instead wanted sales on the last date that appears in your fact table, you could change 'Date'[Date] to FactTable[Date].
The reason LASTDATE works but MAX doesn't is that LASTDATE returns a table with a single date which retains lineage, so can be used for filtering, but MAX just returns a scalar that can't be used for filtering.
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.