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

Distinct Count of Two Columns

Hello all, 

 

I have a Booking Table where I have a Booking ID and a Departure ID for each booking. 

 

I need a measure to calculate the no. of legs which should be the Distinct Depature ID for each Booking ID. 

 

I'm using the following DAX but I don't think I'm getting the correct figure
COUNTROWS(SUMMARIZE(Booking, Booking[Booking ID], Booking[Departure ID]))
 
Thanks in advance!
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try with Departure id?

COUNTROWS(SUMMARIZE(Booking, Booking[Booking Reference], Booking[Departure ID]))

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

View solution in original post

Anonymous
Not applicable

Hi @Anonymous ,

 

My sample data is this

Screenshot 2021-04-06 145911.png

 

The measure

DistinctCount =
CALCULATE (
    DISTINCTCOUNT ( 'Booking Table'[Booking ID] ),
    ALLEXCEPT ( 'Booking Table', 'Booking Table'[Departure ID] )
)

Screenshot 2021-04-06 150322.png

 

You can check details from the attachment.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

My sample data is this

Screenshot 2021-04-06 145911.png

 

The measure

DistinctCount =
CALCULATE (
    DISTINCTCOUNT ( 'Booking Table'[Booking ID] ),
    ALLEXCEPT ( 'Booking Table', 'Booking Table'[Departure ID] )
)

Screenshot 2021-04-06 150322.png

 

You can check details from the attachment.

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Anonymous , Try with Departure id?

COUNTROWS(SUMMARIZE(Booking, Booking[Booking Reference], Booking[Departure ID]))

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

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.

Top Solution Authors