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
ncbshiva
Advocate V
Advocate V

Count based on two columns in two different tables

Hi All,

 

Below are my tables, Order table and Cart table are related by Order ID. Cart and Message tables are related by Cart ID.

 

DAX Question.jpg

 

My requirement is to count the number of Orders by messages. I am expecting below output:

 

Number of OrdersMessages
2Your order is not correct

 

Can anyone help me how to get this output in DAX ?

 

Regards,

Shiva Kumar

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @ncbshiva 

If you use the [Order ID] column from Cart table and use the aggregate type Count (or Count Distinct), you will get the result directly.

050401.jpg

Or you can also create a measure Measure1 = COUNT(Cart[Order ID]) or Measure1 = DISTINCTCOUNT(Cart[Order ID]) and put it in the table.

 
To use both of the above solutions, the relationship's cross-filter direction between Message table and Cart table should be Single (Message table filters Cart table) or Both.
 
Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @ncbshiva 

If you use the [Order ID] column from Cart table and use the aggregate type Count (or Count Distinct), you will get the result directly.

050401.jpg

Or you can also create a measure Measure1 = COUNT(Cart[Order ID]) or Measure1 = DISTINCTCOUNT(Cart[Order ID]) and put it in the table.

 
To use both of the above solutions, the relationship's cross-filter direction between Message table and Cart table should be Single (Message table filters Cart table) or Both.
 
Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
amitchandak
Super User
Super User

@ncbshiva , Hop message, and cart are joined

ithink count should do

 

calculate(count(cart[order id] , not(isblank(Message[cart id])))

 

if needed

calculate(distinctcount(cart[order id] , not(isblank(Message[cart id])))

 

visualize with Message[Message]

Hi,
Thanks for the message.
As mentioned Cart and Message table is joined/related by Cart ID.

 

I tried the dax that you have provided, but i did not get the expected results.

 

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.