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

DAX: Ranking of individuals

Hi everyone,

I have some troubles with PowerBI that I hope someone here can help me with. I have a list of People entering and exiting locations with timestamps that I am trying to convert to a format that would work with Sankey/Chord charts:

 

Current dataset

UserProfileIdAreaNameEnterUtcDate"EnterUtcTimeExitUtcDateExitUtcTime
963566X108.06.201610:43:0108.06.201610:43:32
963566X208.06.201610:44:2008.06.201610:44:54
961627X108.06.201610:50:1808.06.201610:52:31
961627X208.06.201611:09:1608.06.201611:09:16
961627X308.06.201611:10:5808.06.201611:12:28
961627X408.06.201611:45:2208.06.201611:46:43
961627X508.06.201612:03:0808.06.201612:04:01

 

The format I need to have the data in to do sankay/chord charts is

ToFromAmount
   

 

The solution I have come up with is to rank the each row based on individual and time of entry, an afterwards make a lookup on the individuals "next location".

UserProfileIdAreaNameEnterUtcDate"EnterUtcTimeExitUtcDateExitUtcTimeRankNext Area
963566X108.06.201610:43:0108.06.201610:43:321X2
963566X208.06.201610:44:2008.06.201610:44:542-
961627X108.06.201610:50:1808.06.201610:52:311X2
961627X208.06.201611:09:1608.06.201611:09:162X3
961627X308.06.201611:10:5808.06.201611:12:283X4
961627X408.06.201611:45:2208.06.201611:46:434X5
961627X508.06.201612:03:0808.06.201612:04:015-

 

Afterwards I imagine I could use some type of measure with a count formula to summarize the people entering and exiting a location.

 

My issue is that I cant seem to get the rank formula to work since I am not very profficient with PowerBI. I have been trying to use variations of RANKX: but seem to either rank the whole table, or each row individually. Can someone help me with how I can make a formula that only rank the results of each individual? Or can anyone come up with a better solution to my problem?

 

I might also ad that I have been making new columns converting the timestamps to digital formats, so I shouldnt have any issues with the date/time formats..

 

Thank you in advance!

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @Fridm,

 

In your scenario, you can specify the RANKX( ) function to rank records with each [UserProfileId] instance. See:

 

Rank = RANKX(
         FILTER(
         ALLSELECTED(Table1),Table1[UserProfileId]=EARLIER(Table1[UserProfileId])
                   ),
         'Table1'[EnterUtcTime],
     ,1)

 

q1.PNG

 

If you have any question, please feel free to ask.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
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
v-qiuyu-msft
Community Support
Community Support

Hi @Fridm,

 

In your scenario, you can specify the RANKX( ) function to rank records with each [UserProfileId] instance. See:

 

Rank = RANKX(
         FILTER(
         ALLSELECTED(Table1),Table1[UserProfileId]=EARLIER(Table1[UserProfileId])
                   ),
         'Table1'[EnterUtcTime],
     ,1)

 

q1.PNG

 

If you have any question, please feel free to ask.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you, this works great!

 

Best regards,

Michael

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.