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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PowerFabian
Frequent Visitor

Use COUNTROWS with multiple filter on related columns

Hey,

 

i have a problem with my measure. I try to use Countrows on a table based on two columns in a related table. 

 

I have a table "Receipts" (Many-side) and a table "Customers" (One-side) and they are in a Many-to-One relationship. So each receipt record has a column with a CustomerNo that has one record in my table Customer. Now I want to calculate the numer of receipts that meet the criteria of two columns in the related customer table.

 

For example I calculate the number of receipts that possess a customer number which has a address line like that:

Number with addressline= CALCULATE(COUNTROWS(Receipts), Customer[AddressLine]<>"")
--> this works fine for me, ISBLANK isn't a possible solution. but works with <>""
 
Now I want the number of receipts that possess a customer number that has a phone numer OR a mobilephone number in their record. I tried like that:
Number with any phonenumber = CALCULATE(COUNTROWS(Fact_Belege), Dim_Customer[FonPrivate1]<>"" || Dim_Customer[MobileFonPrivate])
 
--> now i get an error code that says expression contains multiple columns, but only one column can be used a true/false expression for a tablefilter. I also tried it with the OR() function, but without a result
 
Can you help me with that, because I dont know how to rewrite my measure.
 
Kind regards,
Fabian
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@PowerFabian , Try a meausre like

 

Number with any phonenumber = CALCULATE(COUNTROWS(Fact_Belege), filter(Dim_Customer,not(isblank(Dim_Customer[FonPrivate1])) || not(isblank(Dim_Customer[MobileFonPrivate]))))

View solution in original post

3 REPLIES 3
pawel_osipowski
Frequent Visitor

Yes, known thing for CALCULATE as it's implicitly using FILTER which pulls logic values from one column: for solutions refer to this: https://www.sqlbi.com/articles/filter-arguments-in-calculate/

 

amitchandak
Super User
Super User

@PowerFabian , Try a meausre like

 

Number with any phonenumber = CALCULATE(COUNTROWS(Fact_Belege), filter(Dim_Customer,not(isblank(Dim_Customer[FonPrivate1])) || not(isblank(Dim_Customer[MobileFonPrivate]))))

Thank you very much for your help. It worked like that for me. 
Regards,

Fabian

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors