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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Create a new sort column based in two columns relationship (sequence)

In Power BI, I have a table called ESTRUTURAS that has two columns: one called 'Equipamento' (name of the equipment) and the other 'EquipamentoVante' which determines the name of the next equipment in the order. I want to create a column that numbers the order of these equipment. The equipment that does not have next equipment is the last equipment in the set. And the equipment that does not appear in the next equipment column is the first equipment in the set. How do I create this new column (numbering the equipment in a given set of 1, 2, 3, ... until the last equipment) in DAX language?

 

#Ultima = ISBLANK('ESTRUTURAS'[EquipamentoVante])      *** column that marks (true) the last equipment in order
 
#First = IF(
NOT(
(ESTRUTURAS[Equipamento]) IN VALUES(ESTRUTURAS[EquipamentoVante])
),
1,
0
)                   ***  column that marks the first equipment (identified as 1)
 
*** All my code attempts result in circular reference or other error.
 
2 ACCEPTED SOLUTIONS
OwenAuger
Super User
Super User

Hi @Anonymous 

I believe we can do something with PATH functions. Exact code would depend on the structure of the data.

Could you post a sample of the ESTRUTURAS table? 

Questions:

  • Is each value in Equipamento unique?
  • If not unique, then is there a grouping column (like Order ID or something else) which groups Equipamento into sets of unique values?

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

Anonymous
Not applicable

Great solution.
I had to create a column inverting the relationship (a column that informs the previous equipment, instead of the one that existed informing the next equipment).
Then just apply the PATH and PATLENGTH functions.

Problem solved.
Thank you very much.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Great solution.
I had to create a column inverting the relationship (a column that informs the previous equipment, instead of the one that existed informing the next equipment).
Then just apply the PATH and PATLENGTH functions.

Problem solved.
Thank you very much.

OwenAuger
Super User
Super User

Hi @Anonymous 

I believe we can do something with PATH functions. Exact code would depend on the structure of the data.

Could you post a sample of the ESTRUTURAS table? 

Questions:

  • Is each value in Equipamento unique?
  • If not unique, then is there a grouping column (like Order ID or something else) which groups Equipamento into sets of unique values?

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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