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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

grouping with dax or power query

Hi, Team please help with the below task.

 

StartTimeEndTimeRequired column
01/07/2020 12:00:05 AM01/07/2020 12:00:07 AM       0
01/07/2020 12:00:06 AM01/07/2020 12:00:07 AM       0
01/07/2020 12:00:07 AM01/07/2020 12:00:07 AM       0
01/07/2020 12:05:18 AM01/07/2020 12:06:52 AM       1
01/07/2020 12:06:42 AM01/07/2020 12:06:42 AM       1
01/07/2020 12:06:42 AM01/07/2020 12:06:42 AM       1
01/07/2020 12:15:54 AM01/07/2020 12:15:56 AM       2
01/07/2020 12:16:03 AM01/07/2020 12:16:06 AM       3
01/07/2020 12:16:27 AM01/07/2020 12:16:39 AM       4
01/07/2020 12:16:39 AM01/07/2020 12:18:30 AM       4
01/07/2020 12:18:30 AM01/07/2020 12:19:52 AM       5
01/07/2020 12:20:41 AM01/07/2020 12:22:27 AM       6
01/07/2020 12:20:42 AM01/07/2020 12:22:27 AM       6
01/07/2020 12:20:42 AM01/07/2020 12:22:27 AM       6
01/07/2020 12:22:27 AM01/07/2020 12:23:25 AM       6
01/07/2020 12:23:00 AM01/07/2020 12:23:15 AM       7
01/07/2020 12:23:00 AM01/07/2020 12:28:01 AM       7
01/07/2020 12:23:42 AM01/07/2020 12:28:03 AM    8

 

If we take the 1st Endtime of the column it should be less than or equal to each row of the Starttime then it will make it as one group and grouping should start with 0, 1, 2, 3....

 @amitchandak,

Thank you in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you so much @amitchandak  it is working perfectly  

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Table.jpg

@amitchandak 

Please find the above image highlighted colors are grouping rule for better understanding, I am expecting the result is "Required Column"

@Anonymous , I tried but I am getting a few diffs. can you check the first column I created is correct as per your conditions?

 

New Time = 
var _ed =[EndTime]  
var _2 = maxx(filter('Table',[StartTime] <=_ed),[StartTime]) 
return _2

Then rank 

Rank = RANKX('Table',[New Time],,ASC,Dense) -1

 

I doubt I have not taken new time correctly here

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
Anonymous
Not applicable

Hi Amit,

 

Thank you for your great support and everything perfect but a few rows are unmatched please have look at below those are highlighted in red color font.Table2.jpg

@Anonymous , Please change new time column as give below and try

 

New Time = 
var _ed =[EndTime]  
var _st =[StartTime]  
var _led = maxx(filter('Table', [StartTime] <EARLIER([StartTime])),[EndTime])
var _2 = if(ISBLANK(_led) ||  [StartTime] > _led ,_ed,_led)

return _2
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
Anonymous
Not applicable

Thank you so much @amitchandak  it is working perfectly  

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.