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.
For a sales visualisation I would like te calculate the sales for each costumer based on the last 5 sales.
Normally would could use the N last days from today. However I'm not intrested to use date but rather the last n orderID's.
Visual the calculation looks like this:
I used:
@Sebas2404 , Create a column like this in order table
orderID Rank = rankx(filter('Table', [Customer] = earlier([customer])), [orderID],,asc,dense)
then try one of the two measures
Measure = CALCULATE(COUNT('Table'[Amount]) ,FILTER(('Table'),'Table'[orderID Rank] >=CALCULATE(max('Table'[orderID Rank])-5,ALLEXCEPT('Table','Table'[process]))))
or
Measure =
VAR __id = MAX ('Table'[Customer] )
VAR __rank = CALCULATE ( MAX('Table'[orderID Rank] ), ALLSELECTED ('Table' ), 'Table'[Customer] = __id )
CALCULATE ( sum ('Table'[Amount] ), VALUES ('Table'[Customer ),'Table'[Customer] = __id,'Table'[orderID Rank] = __rank )
My Latest Blog: https://community.powerbi.com/t5/Community-Blog/Important-Links-every-Power-BI-enthusiastic-should-b...
@amitchandak I Tried the formule orderID Rank = rankx(filter('Table', [Customer] = earlier([customer])), [orderID],,asc,dense) with new colom en that works fine.
THANKS FOR THE FIRST STEP!
With the first measure -> Measure = CALCULATE(COUNT('Table'[Amount]) ,FILTER(('Table'),'Table'[orderID Rank] >=CALCULATE(max('Table'[orderID Rank])-5,ALLEXCEPT('Table','Table'[process]))))
What do you mean with ALLEXCEPT('Table','Table'[process])))) ?
the process is new for me
@amitchandak some addition infortmation regarding the end result:
for each value of SU number I want to sum its own number with the last n SU number and there value for ech Su number in my filter range.
Hopes this clarifies the question.
Thanks in advance
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
61 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |