Hello,
I want to get last 4 weeks sum of sales in the table. In below example column "Previous 4 week Sales".
Please can someone help me here.
Week | Product | Sales | Previous 4 week Sales |
1 | A | 10 | |
2 | A | 10 | |
3 | A | 20 | |
4 | A | 30 | 70 |
5 | A | 40 | 100 |
6 | A | 50 | 140 |
7 | A | 60 | 180 |
8 | A | 70 | 220 |
9 | A | 80 | 260 |
10 | A | 90 | 300 |
1 | B | 5 | |
2 | B | 5 | |
3 | B | 5 | |
4 | B | 10 | 25 |
5 | B | 15 | 35 |
6 | B | 20 | 50 |
7 | B | 25 | 70 |
8 | B | 30 | 90 |
9 | B | 35 | 110 |
10 | B | 40 | 130 |
Solved! Go to Solution.
Hi @sujaymallesh,
Previous 4 week Sales = IF ( 'Weekly Sales'[Week] < 4, BLANK (), CALCULATE ( SUM ( 'Weekly Sales'[Sales] ), FILTER ( ALLEXCEPT ( 'Weekly Sales', 'Weekly Sales'[Product] ), 'Weekly Sales'[Week] <= EARLIER ( 'Weekly Sales'[Week] ) && 'Weekly Sales'[Week] > EARLIER ( 'Weekly Sales'[Week] ) - 4 ) ) )
Best regards,
Yuliana Gu
Hi @sujaymallesh,
Previous 4 week Sales = IF ( 'Weekly Sales'[Week] < 4, BLANK (), CALCULATE ( SUM ( 'Weekly Sales'[Sales] ), FILTER ( ALLEXCEPT ( 'Weekly Sales', 'Weekly Sales'[Product] ), 'Weekly Sales'[Week] <= EARLIER ( 'Weekly Sales'[Week] ) && 'Weekly Sales'[Week] > EARLIER ( 'Weekly Sales'[Week] ) - 4 ) ) )
Best regards,
Yuliana Gu
Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.
Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!
User | Count |
---|---|
213 | |
53 | |
43 | |
42 | |
41 |
User | Count |
---|---|
267 | |
210 | |
73 | |
70 | |
64 |