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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Related table in measure returns no value if one of the tables returns no rows

I have the following measure which works perfrectly when rows are reutned from both tables but when one table returns no rows there is no response not even "Blank".

 

I would like to in the event that one of the tables returns no rows  display "0".

 

Dax meaure

Test = Calculate(

          Countrows(tablea),

           Filter(relatedtable(tableb), and ([Status] = "In Stock", [substatus] = "Available")), tablea[object_type] = 12)

Tableb is not returning any rows as there is no match for [Status] = "In Stock", [substatus] = "Available"

 

Thanks

 

1 ACCEPTED SOLUTION
_elbpower
Resolver III
Resolver III

VAR FilteredTableB = FILTER( RELATEDTABLE(tableb), [Status] = "In Stock" && [substatus] = "Available" ) RETURN IF( COUNTROWS(FilteredTableB) > 0, CALCULATE( COUNTROWS(tablea), FilteredTableB, tablea[object_type] = 12 ), 0 )

View solution in original post

1 REPLY 1
_elbpower
Resolver III
Resolver III

VAR FilteredTableB = FILTER( RELATEDTABLE(tableb), [Status] = "In Stock" && [substatus] = "Available" ) RETURN IF( COUNTROWS(FilteredTableB) > 0, CALCULATE( COUNTROWS(tablea), FilteredTableB, tablea[object_type] = 12 ), 0 )

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.