The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hi All,
I've been struggling with creating the right metric for the last 6 months cumulative sales and i hope that you can help me with it.
In summary, i'm facing issues with blank values and my metric is not considering the period where the data is null.
Please see the below example :
In the below table you can see my original dataset, it reflects the sales by product from Dec-21 to May-22 (6 Months).
As you can see, Product 4 doest not have data from Feb 22 to May 22 .
Same for Product 9, May 22 is blank
When i try to create the metric to calculate the last 6 months of sales per period i face the below issue.
i'm able to have the calculation only for the product without blank values.
as you can see from the below calculated table, i'm calculating the last 6 months of sales for May 22
==> Product 9 and Product 4 are not taken into consideration by my metric as May 22 the starting month is blank.
in the other side, Product 3 is considered eventhough it has some blank datapoints (Not May 22)
This is my metric formula :
Solved! Go to Solution.
@KD13 , with help from the Calendar table, joined to date of your table
Try a measure like this. In the visual use field from Calendar for month year
Rolling 6 = CALCULATE(SUM(sales_table[Sales]),,DATESINPERIOD('00 -Calendar'[Date],MAX('00 -Calendar'[Date]),-6,MONTH))
Rolling 6 = CALCULATE([Net], WINDOW(-11,REL, 0, REL, ADDCOLUMNS(ALLSELECTED('00 -Calendar'[Month Year],'00 -Calendar'[Month Year Sort] ),ORDERBY([Month Year Sort],asc)))
Rolling Months Formula: https://youtu.be/GS5O4G81fww
Continue to explore Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
https://medium.com/@amitchandak/power-bi-window-function-3d98a5b0e07f
@KD13 , with help from the Calendar table, joined to date of your table
Try a measure like this. In the visual use field from Calendar for month year
Rolling 6 = CALCULATE(SUM(sales_table[Sales]),,DATESINPERIOD('00 -Calendar'[Date],MAX('00 -Calendar'[Date]),-6,MONTH))
Rolling 6 = CALCULATE([Net], WINDOW(-11,REL, 0, REL, ADDCOLUMNS(ALLSELECTED('00 -Calendar'[Month Year],'00 -Calendar'[Month Year Sort] ),ORDERBY([Month Year Sort],asc)))
Rolling Months Formula: https://youtu.be/GS5O4G81fww
Continue to explore Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
https://medium.com/@amitchandak/power-bi-window-function-3d98a5b0e07f
Hello,
thanks for your reply, bu thhis suggestion does not solve the issue.
When the starting month of the 6 months period is blank, the calculation stops and does not take into consideration the reamining months.
User | Count |
---|---|
68 | |
63 | |
59 | |
54 | |
28 |
User | Count |
---|---|
182 | |
81 | |
64 | |
46 | |
41 |