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 everyone,
I've been struggling to write a calculated column to solve the following issue.
I've got 4 columns: SKU,PO,Qty ordered and Qty on backorder. I need to create a column called "can_clear_backorders", that will calculate the amount of backorders a PO can clear based on the qty ordered but this needs to be a cumulative sum and it also needs to reset when there is a new value in column SKU.
Any ideas how can I achive this? Sorry if my explanation is not clear enough, I've attached an image with the expected result as an example.
Solved! Go to Solution.
Hi, @georgec96
You can try the following methods. You need to add an index column to Power Query first.
Column:
Max Oty on backorder = MAXX(FILTER('Table',[SKU]=EARLIER('Table'[SKU])),[Qty on backorder])
Cumulative = CALCULATE(SUM('Table'[Qty ordered]),FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Index]<EARLIER('Table'[Index])))
Result =
SWITCH(TRUE(),
[Cumulative] = BLANK ()&& [Qty ordered] <= [Qty on backorder], [Qty ordered],
[Cumulative] = BLANK ()&& [Qty ordered] > [Qty on backorder],[Qty on backorder],
[Max Oty on backorder]-[Cumulative]<0,0,
[Qty ordered]<[Cumulative],[Qty ordered],[Max Oty on backorder]-[Cumulative])
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @georgec96
You can try the following methods. You need to add an index column to Power Query first.
Column:
Max Oty on backorder = MAXX(FILTER('Table',[SKU]=EARLIER('Table'[SKU])),[Qty on backorder])
Cumulative = CALCULATE(SUM('Table'[Qty ordered]),FILTER('Table',[SKU]=EARLIER('Table'[SKU])&&[Index]<EARLIER('Table'[Index])))
Result =
SWITCH(TRUE(),
[Cumulative] = BLANK ()&& [Qty ordered] <= [Qty on backorder], [Qty ordered],
[Cumulative] = BLANK ()&& [Qty ordered] > [Qty on backorder],[Qty on backorder],
[Max Oty on backorder]-[Cumulative]<0,0,
[Qty ordered]<[Cumulative],[Qty ordered],[Max Oty on backorder]-[Cumulative])
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@georgec96 , You back order logic is not clear.
But windows function with partitioned by can help
Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
https://www.youtube.com/watch?v=cN8AO3_vmlY&t=31980s
The information you have provided is not making the problem clear to me. Can you please explain with an example.
Appreciate your Kudos.
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
11 | |
9 | |
6 |