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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

How to Create a unique identifier column based on the combination of two columns?

Hi Everyone,

 

My requirement is to create a new identifier column based on the combination of the two existing columns.

For Example, Let us consider this to be the Sample data. We need to create this ID (First column) based on the combination of "Country & PG" column.

 

IDCountryPGAreaAction
1C1P1A1TRUE
2C1P1A2FALSE
1C1P2A1TRUE
2C1P2A2TRUE
3C1P2A3FALSE
1C1P3A1TRUE
1C2P1A1TRUE
2C2P1A2FALSE

 

We need to increment the ID, if the combination of the Country and PG is same. If one of them seems to change, then again we need to start from the index 1. Can anyone please help me in implementing this ID column. It would be really helpful If you could able to give me the solution file or M code. 

 

Thanks in advance!! 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , First add index column in power query and then try a new column in dax 

 

ID=

countx(filter(Table, [Country] =earlier([country])  && [PG] =earlier([PG]) && [index] <=earlier([index]) ), [index])

 

https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

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

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , First add index column in power query and then try a new column in dax 

 

ID=

countx(filter(Table, [Country] =earlier([country])  && [PG] =earlier([PG]) && [index] <=earlier([index]) ), [index])

 

https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

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 @amitchandak ,

 

Thanks alot for your quick response. It worked as expected. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.