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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
danielmbaquero
Regular Visitor

Using RELATEDTABLE to return the first, second... value that meets a condition in a 1:Many relation

Good day people,

 

I have two tables, one called "Times" and the other called "Operations". Both tables have an operation ID. The "Times" table contains data about the status of the operation and the time that the status begin for all of the possible statues. I would like to add a new column to the "Operations" table with the time an specific status began. Also, an operation can start the same status many times. I would like to have a column for the first time, one column for the second time...

 

"Times" table looks like this:

IDNew StatusTime
1A18/2/2019 14:21:36
1B18/2/2019 18:30:00
1A19/2/2019 7:30:00
2A18/2/2019 9:30:00
2B18/2/2019 11:20:00
3A19/2/2019 7:30:00
3B19/2/2019 9:30:00
3C19/2/2019 11:30:00
3D19/2/2019 14:30:00

 

The "Operations" table just have the operation id.

I want to add columns so it looks like this:

 

IDTime first ATime second ATime first BTime first CTime first D
118/2/2019 14:21:3619/2/2019 7:30:0018/2/2019 18:30:00  
218/2/2019 9:30:00 18/2/2019 11:20:00  
319/2/2019 7:30:00 19/2/2019 9:30:00 19/2/2019 11:30:0019/2/2019 14:30:00

 

I have been traying to use the SELECTCOLUMS and RELATEDTABLE functions but I have not figure out how both works.

Thanks for your help!

4 REPLIES 4
camargos88
Community Champion
Community Champion

Hi @danielmbaquero ,

 

You should do it using Power Query.

Can you paste both tables here ? Also the structure should be little bit different, like a column to order the status number (if repeated).

 

So you can achieve the visual using matrix.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



@danielmbaquero it is pretty straight forward except, do you want second time only for "A" or others as well?



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.

@parry2k  I want the second for others as well. And there can be a third, fourth... for all statues

@camargos88  answer about the structure can  be right. Maybe the structure should looks like this:

IDStatusRe-processTime
1A

First time

.....
1ASecond time.....
1BFirst time.....
2AFirst time.....
2BFirst time.....

@danielmbaquero with simple DAX I already got this

 

image.png

 



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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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