Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
HI Team,
I've requirement to calculate two different conditions:
1. To calculate cummulative sum till 6th row
2. To calculate Rollling 6 months sum (After 6 th row)
Reference Link for PBI: https://1drv.ms/u/s!Au-aOkl1BoHuhytgh_iqEh6UG4WA?e=IwUWDN
Formula:
Reference Link for PBI: https://1drv.ms/u/s!Au-aOkl1BoHuhytgh_iqEh6UG4WA?e=IwUWDN
Please let me know if you need anything
Thanks In Advance
Solved! Go to Solution.
Hi,
I suggest having a Dim-Date table and using the time intelligence function in DAX to create a measure.
However, if you do not have a Dim-Date table, please check the below picture and the attached pbix file.
Create a calculated column in the table, that is the Month Number CC, and then create measures like below.
Hi,
I suggest having a Dim-Date table and using the time intelligence function in DAX to create a measure.
However, if you do not have a Dim-Date table, please check the below picture and the attached pbix file.
Create a calculated column in the table, that is the Month Number CC, and then create measures like below.
Hi @Anonymous
Do you need a DAX Calculated column? And the logic is about June and differentiate years?
Cum_NS =
VAR CurMonth = MONTH(Sheet3[Date])
RETURN
IF(CurMonth<7, SUMX(FILTER(Sheet3,Sheet3[Year]=EARLIER(Sheet3[Year])&&MONTH(Sheet3[Date])<=CurMonth),Sheet3[NS]),
SUMX(FILTER(Sheet3,Sheet3[Year]=EARLIER(Sheet3[Year])&&MONTH(Sheet3[Date])<=CurMonth&&MONTH(Sheet3[Date])>=CurMonth-6),Sheet3[NS]))
Hi @Vera_33 ,
Thanks for the response. Yes we need calculated column and need some changes in formula
In the formula need changes.
1. We don't need to differentiate years means starting from the 7th row in table same logic shiould be applied to till the last .
For example: in the current formula, from every every year stating month it will be recalculated .
Expected : It shouldn't be recalculated and from 7th row it should be be rolling 6 months sum irrespective of the year.
2. Logic is not related on June month and it should be related on the rownumber
means if the data start from jun 2018 to 2021 nov then the first 6 rows should be cummulative after that it should be last 6 months rolling sum.
Please let me know if you need any details
Thanks In Advance
Hi @Anonymous
So does the table sort by date? We can add the Row number based on date?
CurRow = COUNTROWS(FILTER(Sheet3,Sheet3[Date]<=EARLIER(Sheet3[Date])))
Cum_NS =
VAR CurR=Sheet3[CurRow]
RETURN
IF([CurRow]<7, SUMX(FILTER(Sheet3,Sheet3[CurRow]<=CurR),Sheet3[NS]),
SUMX(FILTER(Sheet3,Sheet3[CurRow]>=CurR-6&&Sheet3[CurRow]<=CurR),Sheet3[NS]))
Otherwise you need to add Index column as Row number via Power Query
Please also consider the size and the suggestion from @Jihwan_Kim
User | Count |
---|---|
25 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
25 | |
12 | |
11 | |
10 | |
6 |