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

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

Reply
dkenniston
Frequent Visitor

How to get a measure to return multiple rows for every condition evaluated as TRUE

Hi there,

I'm writing a DAX measure that I'd like to return multiple rows for every condition evaluated as TRUE.

 

I have the following, for example:

 

VAR maritalStatus = SELECTEDVALUE('New Client Intake Responses'[Marital Status])
VAR atRiskOfDivorce = SELECTEDVALUE('FamilyLife Profile'[Change in marital status (divorce)])
VAR atRiskOfWidowhood = SELECTEDVALUE('FamilyLife Profile'[Change in marital status (widowhood)])
RETURN
SWITCH(
    TRUE(),
    maritalStatus = "Married" && atRiskOfDivorce IN {"Currently experiencing", "Anticipate short- to mid-term", "Anticipate long-term"}, "Div Risk (set tax status to MFS)",
    maritalStatus = "Married" && atRiskOfWidowhood IN {"Currently experiencing", "Anticipate short- to mid-term"}, "Anticipated loss of spouse"
)

 

In the case above, it's possible for both of the criteria to be true. And if both are true, I'd like this measure to return both

"Div Risk (set tax status to MFS)" and "Anticipated loss of spouse". But as written, it only returns the first criteria evaluated as true: "Div Risk (set tax status to MFS)".
 
What would be the best way to go about this? Would really prefer to keep these in a single measure, because it'll make the report look cleaner..
 
Thanks!
1 ACCEPTED SOLUTION

I think getting to an answer would require more sophisticated DAX than I'm able to come up with, so I've modified the data model instead. Closing this one out. Thanks anyway for all who viewed and to @amitchandak for the opening shot!

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@dkenniston , based on what I got, you need a measure like

 

VAR maritalStatus = SELECTEDVALUE('New Client Intake Responses'[Marital Status])
VAR atRiskOfDivorce = SELECTEDVALUE('FamilyLife Profile'[Change in marital status (divorce)])
VAR atRiskOfWidowhood = SELECTEDVALUE('FamilyLife Profile'[Change in marital status (widowhood)])
RETURN Countrow(filter(Table, not(Isblank(
SWITCH(
TRUE(),
maritalStatus = "Married" && atRiskOfDivorce IN {"Currently experiencing", "Anticipate short- to mid-term", "Anticipate long-term"}, "Div Risk (set tax status to MFS)",
maritalStatus = "Married" && atRiskOfWidowhood IN {"Currently experiencing", "Anticipate short- to mid-term"}, "Anticipated loss of spouse"
))) ) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak, thank you so much for the response!

 

Just tried adding COUNTROWS(FILTER('New Client Intake Responses', NOT(ISBLANK(  

before the SWITCH statement. 

 

It returned the number 1. 

 

Open to other suggestions though - thanks again!

I think getting to an answer would require more sophisticated DAX than I'm able to come up with, so I've modified the data model instead. Closing this one out. Thanks anyway for all who viewed and to @amitchandak for the opening shot!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.