Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
euro_sree
Regular Visitor

Facing problem with ABC Analysis. In the last two rows I am getting blank value for ABC Analysis

Hi Friends

I am facing a problem when doing the ABC analysis. In the last two records I am not getting no value for ABC analysis. In the last two records the cost of the part is same therefore the RANK has tied up.

My DAX formulas are as below

PartRank = RankX(all(PartInfo),PartInfo[Calculated_PartCost],,Desc,Dense)
CumulativeCost = CALCULATE([TotalMtlCost],filter(PartInfo,PartInfo[PartRank]<=EARLIER(PartInfo[PartRank],1)))
CumulativeCostPercentage = Divide(PartInfo[CumulativeCost],[TotalCostWOFilter],0)
ABC Analysis = Switch(
True(),
PartInfo[CumulativeCostPercentage]<= .40,"A",
PartInfo[CumulativeCostPercentage]<= .70,"B",
PartInfo[CumulativeCostPercentage]<= 1,"C"
)
Could any body suggest what the mistake is. The below are the last few records of the table

Part_PartNumPart_PartDescriptionPart_ClassIDPart_IUMPart_QtyBearingPart_CreatedOnPart_CreatedByPartPlant_BackFlushPartBin_OnhandQtyCalculated_PartCostCalculated_LastTranDatePart_TrackLotsPartBin_LotNumPartRankCumulativeCostCumulativeCostPercentageCostPercentABC Analysis
PRHN06DM_SS304Nut Ss304RMHWEATrue22-Dec-22managerFalse136.506-Nov-24False 8397635390.823557099.9997650%0.00%C
PRHW12PL_SS316Plain Washer SS 316RMHWEATrue10-Jan-25PU02False205.94407-Feb-25False 8407635396.767557099.9998428%0.00%C
PCSPG0059TapePGNCEATrue25-Mar-22managerFalse64.814-Feb-25False 8417635401.567557099.9999057%0.00%C
PRHS10025SA_SS304Allen socket head Screw SS 304RMHWEATrue25-Mar-22managerFalse43.606-Dec-24False 8427635408.7675570100.0000000%0.00% 
PRHS04016PS_SS304Pan head screw SS 304RMHWEATrue08-Jun-23PU01False153.606-Dec-24False 8427635408.7675570100.0000000%0.00% 

 

4 REPLIES 4
Anonymous
Not applicable

Hi @euro_sree ,

 

I tried your DAX and it works fine.

 

ABC Analysis = 
SWITCH(
    TRUE(),
    PartInfo[CumulativeCostPercentage] <= 0.40, "A",
    PartInfo[CumulativeCostPercentage] <= 0.70, "B",
    PartInfo[CumulativeCostPercentage] <= 1, "C"
)

 

vtangjiemsft_0-1740033065241.png

 

Please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

euro_sree
Regular Visitor

@bhanu_gautam  Thanks for your response. I tried the code given by you

PartRank = RANKX(ALL(PartInfo),PartInfo[Calculated_PartCost] + (PartInfo[Part_PartNum] * 1e-10),,DESC,DENSE)

This did not work as my partnum is alpha numeric so it does not accept the expresssion PartNum *1e-10. Instead of that I tried PartRank = RANKX(ALL(PartInfo),Concatenate(PartInfo[Calculated_PartCost],PartInfo[Part_PartNum]),,DESC,DENSE). In this I am getting the rank without repeating but the ranks are wrong and its not in the descending order of part cost. In the last row of ABC analysis I am also not get the value.

Anonymous
Not applicable

Hi @euro_sree ,

 

Whether the advice given by bhanu_gautam has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.

 

Best Regards,

Neeko Tang

bhanu_gautam
Super User
Super User

@euro_sree Modify the PartRank calculation to include a secondary column for tie-breaking:
PartRank = RANKX(
ALL(PartInfo),
PartInfo[Calculated_PartCost] + (PartInfo[Part_PartNum] * 1e-10),
,
DESC,
DENSE
)

 


Ensure the CumulativeCost and CumulativeCostPercentage calculations remain the same:
CumulativeCost = CALCULATE(
[TotalMtlCost],
FILTER(PartInfo, PartInfo[PartRank] <= EARLIER(PartInfo[PartRank], 1))
)

 

CumulativeCostPercentage = DIVIDE(
PartInfo[CumulativeCost],
[TotalCostWOFilter],
0
)


The ABC Analysis calculation remains the same:
ABC Analysis = SWITCH(
TRUE(),
PartInfo[CumulativeCostPercentage] <= 0.40, "A",
PartInfo[CumulativeCostPercentage] <= 0.70, "B",
PartInfo[CumulativeCostPercentage] <= 1, "C"
)
By adding a small value based on Part_PartNum to the Calculated_PartCost in the PartRank calculation, you ensure that each part gets a unique rank even if the costs are the same. This should resolve the issue with the last two records not getting an ABC analysis value.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.