Sum sales for max date in a month?

Dan80

New Member
Joined
Apr 28, 2016
Messages
22
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
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
could you post a small sample of your data?
 
Upvote 0
Hi 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.

Cheers,
Owen :)
 
Upvote 0

Forum statistics

Threads
1,215,388
Messages
6,124,641
Members
449,177
Latest member
Sousanna Aristiadou

We've detected that you are using an adblocker.

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.
Go back
Back
Top