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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
techiebee
Frequent Visitor

DAX count based on multiple conditions of multiple columns

Hi All,

I am facing an issue while creating a DAX calculated measure in tabular model SQL Server 2014. 
The dimension table has data like

CategoryCode   TypeCode   ItemCode      ItemSize
     C1                    P1              1                     S
     C1                    P1              2                     M
     C1                    P1              3                     L
     C2                    P2              4                     S
     C2                    P2              5                     M
     C3                    P3              6                     S
     C3                    P3              7                     M

I want to write a DAX expression to calculate
(if count of TypeCodes which fall under CategoryCode C1 and C2 and ItemSize in S,M,L)<>0 then "FR"
((if count of TypeCodes which fall under CategoryCode C1 and C2 and ItemSize in S,L)<>0) AND ((if count of TypeCodes which falls under CategoryCode C1 and C2 and ItemSize in M)=0 then "PR")

Kindly help me in implementing this logic.
Thank You.

1 ACCEPTED SOLUTION
Baskar
Resident Rockstar
Resident Rockstar

Hi Dude , 

 

Try this one . here i used your first condition only rest of other condition u could add .

 

 

 

Condition Check =

switch ( TRUE(),
CALCULATE( COUNTA(Forum[TypeCode]),FILTER(Forum,
AND( OR( Forum[CategoryCode ] = "C1" , Forum[CategoryCode ] = "C2" ) ,
OR( Forum[ItemSize] = "S" , OR( Forum[ItemSize] = "M", Forum[ItemSize] = "L" )
)
)
)) <> 0 , "FR"

, "Other Condition"
)

1.JPG

 

 

 

 

View solution in original post

3 REPLIES 3
Baskar
Resident Rockstar
Resident Rockstar

Hi Dude , 

 

Try this one . here i used your first condition only rest of other condition u could add .

 

 

 

Condition Check =

switch ( TRUE(),
CALCULATE( COUNTA(Forum[TypeCode]),FILTER(Forum,
AND( OR( Forum[CategoryCode ] = "C1" , Forum[CategoryCode ] = "C2" ) ,
OR( Forum[ItemSize] = "S" , OR( Forum[ItemSize] = "M", Forum[ItemSize] = "L" )
)
)
)) <> 0 , "FR"

, "Other Condition"
)

1.JPG

 

 

 

 

Cool. It worked !!  Thanks a lot

Always welcome my friend

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

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.

March Power BI Update Carousel

Power BI Community Update - March 2026

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