Forum Discussion
iamhuz
3 years agoFrequent Visitor
Calculate Last 10 days with specific condition
I have a Sales table like below, I want to create a measure for the last 10 days. Since I don't have data for 01-Apr-2023 so it should consider 23-Mar-23 as my 10th day. Note that my dates can be ch...
- 3 years ago
Ah okay,
if you wrap the rank measure in a filter to calculate the amount based on the rank that is less than 10, that should work. try this:
Measure =CALCULATE(sum('Table'[Amount]),filter('Table',RANKX (FILTER ( ALLSELECTED ( 'Table' ),'Table'[Date]='Table'[Date]),CALCULATE ( SELECTEDVALUE ( 'Table'[Date] ) ),,DESC,DENSE)<10))
iamhuz
3 years agoFrequent Visitor
Hi DOLEARY85, Basically I'd like to calculate the last 10 days' sales and show them on a card without any slicer or a filter.
DOLEARY85
Resident Rockstar
3 years agoAh okay,
if you wrap the rank measure in a filter to calculate the amount based on the rank that is less than 10, that should work. try this:
Measure =
CALCULATE(sum('Table'[Amount]),filter('Table',RANKX (
FILTER ( ALLSELECTED ( 'Table' ),'Table'[Date]='Table'[Date]),
CALCULATE ( SELECTEDVALUE ( 'Table'[Date] ) ),
,
DESC,
DENSE
)<10))