Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I've been trying create a unique ID using a measure based on a category to allow filtration. For example I've the following table, and I would like to create a measure that for each "location" I would had a diferent ID (1,2,3,..)
Tablename: sensors
ID | Instalation ID | Sensor | ConfigFile | Location | ||||
1 | 1 | Pressure | sensorF1.txt | room1 | ||||
2 | 1 | Temperature | sensorF2.txt | room1 | ||||
3 | 1 | Pressure | sensorF3.txt | house | ||||
4 | 1 | Temperature | sensorF4.txt | house | ||||
5 | 1 | Humidity | sensorF5.txt | room2 | ||||
6 | 1 | Temperature | sensorF6.txt | room2 | ||||
7 | 1 | Humidity | sensorF7.txt | outside | ||||
8 | 1 | Temperature | sensorF8.txt | outside | ||||
1 | 2 | Pressure | sensorF1.txt | room1 | ||||
2 | 2 | Temperature | sensorF2.txt | room1 | ||||
3 | 2 | Pressure | sensorF3.txt | house | ||||
4 | 2 | Temperature | sensorF4.txt | house | ||||
5 | 2 | Humidity | sensorF5.txt | room2 | ||||
6 | 2 | Temperature | sensorF6.txt | room2 | ||||
7 | 2 | Humidity | sensorF7.txt | outside | ||||
8 | 2 | Temperature | sensorF8.txt | outside |
The output would be:
ID | Instalation ID | Sensor | ConfigFile | Location | UniqueID | |||||
1 | 1 | Pressure | sensorF1.txt | room1 | 1 | |||||
2 | 1 | Temperature | sensorF2.txt | room1 | 1 | |||||
3 | 1 | Pressure | sensorF3.txt | house | 2 | |||||
4 | 1 | Temperature | sensorF4.txt | house | 2 | |||||
5 | 1 | Humidity | sensorF5.txt | room2 | 3 | |||||
6 | 1 | Temperature | sensorF6.txt | room2 | 3 | |||||
7 | 1 | Humidity | sensorF7.txt | outside | 4 | |||||
8 | 1 | Temperature | sensorF8.txt | outside | 4 |
I've tried to use the measure bellow. but, the EARLIER does not work in the measure.
Do anyone has any ideia how could I do something like that?
Solved! Go to Solution.
@amelo you can achieve that with following two measures
_maxID = MAX(t1[Location])
_rank = RANKX(ALL(t1),[_maxID],,ASC,Dense)
and if you want the ranking to be partitioned by Installion ID
Measure = RANKX(FILTER(ALL(t1),t1[Instalation ID]=MAX(t1[Instalation ID])),CALCULATE(MAX(t1[Location])),,ASC,Dense)
@amelo you can achieve that with following two measures
_maxID = MAX(t1[Location])
_rank = RANKX(ALL(t1),[_maxID],,ASC,Dense)
and if you want the ranking to be partitioned by Installion ID
Measure = RANKX(FILTER(ALL(t1),t1[Instalation ID]=MAX(t1[Instalation ID])),CALCULATE(MAX(t1[Location])),,ASC,Dense)
Thank you!! Works like a charm!!!
Well it is neet trick!
@amelo do you want a unique id between each Installation Id? The output you showed is only for Installation ID, not showing both the IDs, the solution depends on how you want it with different installation ids.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Oh thats because I'm filtering to produce a report for instalation. So, only one instalation will be tested at each time.
User | Count |
---|---|
98 | |
76 | |
75 | |
48 | |
27 |