Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Rejection Sequence Tracking:
For each Material_Code, I need to check if the Rej Qty is greater than 0 for two consecutive months.
If Rej Qty > 0 for consecutive months, I need to start with "CS0.1" and increment the sequence for each rejection:
First rejection in a consecutive pair: "CS0.1"
Second rejection in a consecutive pair: "CS0.2"
If the rejection continues in consecutive months, it should be labeled as "CS1", "CS2", etc.
Reset on "No Rej":
If at any point the Rej Qty = 0 (i.e., "No Rej"), the counter should reset.
After a "No Rej", the sequence should start again from "CS0.1" when a rejection occurs in the next month.
Example Scenario:
April 2025: Rej Qty > 0 → CS0.1
May 2025: Rej Qty > 0 → CS0.2 (since it's consecutive)
June 2025: Rej Qty > 0 → CS1 (new sequence)
July 2025: Rej Qty > 0 → CS2
August 2025: Rej Qty = 0 → No Rej
September 2025: Rej Qty > 0 → CS0.1 (reset after "No Rej")
October 2025: Rej Qty = 0 → No Rej
November 2025: Rej Qty > 0 → CS0.1
December 2025: Rej Qty > 0 → CS0.2 (consecutive again)
January 2026: Rej Qty > 0 → CS1 (new sequence)
I need help creating a DAX formula that can:
Track consecutive rejection months (Rej Qty > 0).
Start the counter with CS0.1, increment to CS0.2, CS1, CS2, etc.
Reset the counter when Rej Qty = 0 and restart with CS0.1 after the "No Rej" period.
The formula should handle these rules for each Material_Code.
I've tried using EARLIER, CALCULATE, and FILTER in DAX, but I am running into issues with handling the reset of the counter after "No Rej". How can I achieve this logic in DAX?
Here is the sample table and output i want
Rej Qty | _Month_Year | _Cs | Fiscal Year | Material_Code | Output1 | Output2 |
10 | Apr-21 | CS0 | 2022 | 86820E_S67 | CS0.1 | Incident1 |
4 | May-21 | CS0 | 2022 | 86820E_S67 | CS0.2 | Incident2 |
26 | Jun-21 | CS1 | 2022 | 86820E_S67 | CS1 | CS1 |
2 | Jul-21 | CS2 | 2022 | 86820E_S67 | CS2 | CS2 |
25 | Aug-21 | CS3 | 2022 | 86820E_S67 | CS3 | Escalation |
13 | Sep-21 | CS4 | 2022 | 86820E_S67 | CS4 | De-rating MSA |
0 | Oct-21 | No Rej | 2022 | 86820E_S67 | No rej | No rej |
5 | Nov-21 | CS0 | 2022 | 86820E_S67 | CS0.1 | Incident1 |
4 | Dec-21 | CS0 | 2022 | 86820E_S67 | CS0.2 | Incident2 |
0 | Jan-22 | No Rej | 2022 | 86820E_S67 | No rej | No rej |
0 | Feb-22 | No Rej | 2022 | 86820E_S67 | No rej | No rej |
3 | Mar-22 | CS0 | 2022 | 86820E_S67 | CS0.1 | Incident1 |
0 | Apr-22 | No Rej | 2023 | 86820E_S67 | No rej | No rej |
for output2 need
Solved! Go to Solution.
Hi @Sah_123 ,
Thanks for sharing your detailed requirements! Based on your scenario,below are the step-by-step instructions with sample data and DAX queries which might help you to get the desired output.
Please find the below DAX queries:
1.Create a column to sort the months using below:
MonthSort = FORMAT([_Month_Year], "YYYYMM")
2.Create a Calculated column to look up the previous month's Rej Qty :
Hi Sah_123 ,
Could you please confirm if you've resolved the issue? If so, sharing the solution here ,it would be helpful for other community members who may have similar issues.If our answer addressed your query,consider accepting it as solution.
Thank you for being part of the Microsoft Fabric Community.
Pallavi G
Hi @Sah_123 ,
Could you please confirm if the issue has been resolved ? If a solution has been found, it would be greatly appreciated if you could share your insights with the community. This would be helpful for other members who may encounter similar issues.
Thank you for your understanding and assistance.
Hi @Sah_123 ,
Has the issue been resolved on your end? If so, please share your solution and mark it as "Accept as Solution." This will assist others in the community who are dealing with similar problems and help them find a solution more quickly.
Thank you.
Hi, @v-pagayam-msft thank you for your response, the ouput what i am looking for is different,
Rej Qty | _Month_Year | _Cs | Fiscal Year | Material_Code | Output1 | Output2 |
10 | Apr-21 | CS0 | 2022 | 86820E_S67 | CS0.1 | Incident1 |
4 | May-21 | CS0 | 2022 | 86820E_S67 | CS0.2 | Incident2 |
26 | Jun-21 | CS1 | 2022 | 86820E_S67 | CS1 | CS1 |
2 | Jul-21 | CS2 | 2022 | 86820E_S67 | CS2 | CS2 |
25 | Aug-21 | CS3 | 2022 | 86820E_S67 | CS3 | Escalation |
13 | Sep-21 | CS4 | 2022 | 86820E_S67 | CS4 | De-rating MSA |
0 | Oct-21 | No Rej | 2022 | 86820E_S67 | No rej | No rej |
5 | Nov-21 | CS0 | 2022 | 86820E_S67 | CS0.1 | Incident1 |
4 | Dec-21 | CS0 | 2022 | 86820E_S67 | CS0.2 | Incident2 |
0 | Jan-22 | No Rej | 2022 | 86820E_S67 | No rej | No rej |
0 | Feb-22 | No Rej | 2022 | 86820E_S67 | No rej | No rej |
3 | Mar-22 | CS0 | 2022 | 86820E_S67 | CS0.1 | Incident1 |
0 | Apr-22 | No Rej | 2023 | 86820E_S67 | No rej | No rej |
output column not matching with your solution.
Hi @Sah_123 ,
Thanks for sharing your detailed requirements! Based on your scenario,below are the step-by-step instructions with sample data and DAX queries which might help you to get the desired output.
Please find the below DAX queries:
1.Create a column to sort the months using below:
MonthSort = FORMAT([_Month_Year], "YYYYMM")
2.Create a Calculated column to look up the previous month's Rej Qty :
Hi @Sah_123 ,
Thank you for reaching ou to us.I am happy to help!
Upon my understanding,to correctly track rejection sequences and assign appropriate labels, follow these structured steps:
1.create a calculated column using below:
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
69 | |
60 | |
51 | |
36 | |
36 |
User | Count |
---|---|
84 | |
70 | |
58 | |
45 | |
44 |