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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
countryfan_nt
Regular Visitor

Creating Unique Group numbers based on conditions on DAX.

Hello friends, Hope all is well! I need your help please.

I wish like the image below to create a unique Group numbering based on a number of conditions on DAX or PQ. The image below is a sample but in reality it is a CSV file that was imported by Power Query.

 

The conditions are:

A. If all have same project name (column G)
B. If all have same PatientID (column E)
C. If Clinic in one Row is “ER Clinic” and in other rows any other clinic (Column C)
D. AND the date of ER Clinic “InvoiceDate” must be equal to OR lower than any other clinic Date by only 2 days (column D)

Capture.PNG

 

Thank you very much in advance! 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @countryfan_nt,

I'd like to suggest you enter to query editor to use 'add index column' and 'group by' features to achieve your requirements. You can refer to the following blog to modify the grouped fields to assign index numbers based on the groups:

Create Row Number for Each Group in Power BI using Power Query - RADACAD

For Dax version, you can refer to the below thread to use ISONORAFTER function to generate a sort number based on multiple columns:

Sorting by multiple columns 
Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

HI @countryfan_nt,

I'd like to suggest you enter to query editor to use 'add index column' and 'group by' features to achieve your requirements. You can refer to the following blog to modify the grouped fields to assign index numbers based on the groups:

Create Row Number for Each Group in Power BI using Power Query - RADACAD

For Dax version, you can refer to the below thread to use ISONORAFTER function to generate a sort number based on multiple columns:

Sorting by multiple columns 
Regards,

Xiaoxin Sheng

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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