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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Mack1int
Frequent Visitor

Formula Classification Help

Good Morning All,

 

 I am struggling with this formula it works for when the number of rows is 2 and the cumulated segmentation however when i put in the the extra count of 3 rows it doesn't classify them "A","B" and "C", instead it comes up with an error. Any help would be greatly appreciated.

 

Many Thanks

 

ABC Product =
VAR NoOfRows =
COUNTROWS (
CALCULATETABLE ( ABC, ALLEXCEPT ( ABC, ABC[Location], ABC[Brand] ) )
)
RETURN
SWITCH (
TRUE (),
NoOfRows = 2, IF (
RANKX (
CALCULATETABLE ( ABC, ALLEXCEPT ( ABC, ABC[Location], ABC[Brand] ) ),
ABC[Sales Revenue]
)
= 1,
"A",
"B"
),
NoOfRows = 3, IF (
RANKX (
CALCULATETABLE ( ABC, ALLEXCEPT ( ABC, ABC[Location], ABC[Brand] ) ),
ABC[Sales Revenue]
)
= 1,
"A",
"B",
“C”
),

ABC[Cumulated Percentage] <= 0.8, "A",
ABC[Cumulated Percentage] <= 0.95, "B",
"C"
)

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Mack1int,

Please change your DAX formula to the following:

ABC Product = 
VAR NoOfRows =
COUNTROWS (
CALCULATETABLE ( ABC, ALLEXCEPT ( ABC, ABC[Location], ABC[Brand] ) )
)
RETURN
SWITCH (
TRUE (),
NoOfRows = 2, IF (
RANKX (
CALCULATETABLE ( ABC, ALLEXCEPT ( ABC, ABC[Location], ABC[Brand] ) ),
ABC[Sales Revenue]
)
= 1,
"A",
"B"
),
NoOfRows = 3, IF (
RANKX (
CALCULATETABLE ( ABC, ALLEXCEPT ( ABC, ABC[Location], ABC[Brand] ) ),
ABC[Sales Revenue]
)
= 1,
"A",
IF (
RANKX (
CALCULATETABLE ( ABC, ALLEXCEPT ( ABC, ABC[Location], ABC[Brand] ) ),
ABC[Sales Revenue]
)
= 2,"B",
"C"
)),
ABC[Cum Percent] <= 0.8, "A",
ABC[Cum Percent] <= 0.95, "B",
"C"
)

1.PNG

Regards,
Lydia

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Mack1int,

Please change your DAX formula to the following:

ABC Product = 
VAR NoOfRows =
COUNTROWS (
CALCULATETABLE ( ABC, ALLEXCEPT ( ABC, ABC[Location], ABC[Brand] ) )
)
RETURN
SWITCH (
TRUE (),
NoOfRows = 2, IF (
RANKX (
CALCULATETABLE ( ABC, ALLEXCEPT ( ABC, ABC[Location], ABC[Brand] ) ),
ABC[Sales Revenue]
)
= 1,
"A",
"B"
),
NoOfRows = 3, IF (
RANKX (
CALCULATETABLE ( ABC, ALLEXCEPT ( ABC, ABC[Location], ABC[Brand] ) ),
ABC[Sales Revenue]
)
= 1,
"A",
IF (
RANKX (
CALCULATETABLE ( ABC, ALLEXCEPT ( ABC, ABC[Location], ABC[Brand] ) ),
ABC[Sales Revenue]
)
= 2,"B",
"C"
)),
ABC[Cum Percent] <= 0.8, "A",
ABC[Cum Percent] <= 0.95, "B",
"C"
)

1.PNG

Regards,
Lydia

Thank you so much @Anonymous

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.