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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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]

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.