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
hp0655
Frequent Visitor

DAX to count number of distinct values in one column for paired value permutations in other column

This one's hard to describe, so better to show.

 

If I have the example data below, how can I create a table that tallies the number of common trip_ids for a pair of stations? In real-world terms, I want to count the number of trains (each has a unique trip_id) that serves a pair of stations.

 

hp0655_0-1629320540932.png

My desired matrix and/or flat table would look like this (though it would be ok to have the identical pairs (e.g., CUS-CUS) also included, if that's easier:

hp0655_0-1629321664802.png

 

Note that the separate stop_id_1 and stop_id_2 don't exist in the dataset - I assume I'd need to define them somehow in the calculated table.

 

Would much appreciate any help here! This is beyond my expertise.

 

1 REPLY 1
lbendlin
Super User
Super User

Please provide sample data in usable format (not as a picture - maybe insert into a table?) .

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