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
Anonymous
Not applicable

Most efficient way to create reference tables from original table

Hi there,

 

I have a primary table in my PowerBI model, and want to perform several transformations to add custom columns.  

 

For example, my primary table contains a unique Customer ID per row, with a column for Parent ID.  For some rows, these two values will be the same, i.e. it's a Parent record, but for others they will differ, i.e. they are a child record.  Every individual row has a Last Booking Date.

 

I want to add a new column to my primary table which shows the most recent Last Booking Date for each differing Parent ID, so I have created a duplicate of my primary table, grouping on Parent ID and the MAX of Last Booking Date.

 

I've then merged this second table to the primary table, joining on Parent ID, and then expanded the columns for MAX Last Booking Date.

 

This achieves my goals, and I get the data I require in the new column, however I'm concerned that it might not be the most efficient mechanism to do so.

 

I've a number of similar scenarios I've run against my primary table, ending up with 3 duplicate tables - against which I've performed various types of data transformation.

 

It now takes quite a long time to refresh table previews, and I'm wondering if it's because each of the tables need to refresh in full to update my primary table.

 

Is there a more efficient way of achieving this type of manipulation, e.g. instead of duplicating the primary table, should I be referencing it?

 

Hope this makes sense anyway!

 

Thanks

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

That's why I asked you to share sample data...Your previous sample is incomplete.

Try this:

Last Booking Date =
MAXX (
    FILTER (
        ALL ( table ),
        [Parent Cust ID] = SELECTEDVALUE ( table[Parent Cust ID] )
    ),
    [Booking Date]
)

  

Best Regards,

Community Support Team _Janey

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Hi @v-janeyg-msft ,

 

Sorry, I'm not sure I understand.  The column you've highlghted in this sample table is the expected result.

 

Both rows have the same Parent Cust ID, but differing Cust Last Booked Date.  The Parent Last Booking Date is displaying the MAX Cust Last Booking Date across all child entities.

 

Naturally, this value will be repeated or all rows with the same Parent Cust ID, but this is not a problem.

 

Hope that clarifies?

 

C

@Anonymous  So you have no questions, do you?

Anonymous
Not applicable

Erm, not sure I understand.

 

do have a question...as described...

 

"Ok, so next problem (sorry!).  I actually need to expose the MAX(Last Booking Date) across all Customer entities associated with the Parent Customer.  If I create a measure using Last Booking Date = MAX ( Table[Booking Date] ) then I get the Last Booking Date for the individual Customer in my report - which is at Customer Level."

 

That table was jsut an example of the Parent Cust Last Booking Date column I'm hoping to create.

@Anonymous  

 

If you only want to display the max date.

You can try:

Last Booking Date =
MAXX ( ALL ( table ), [Booking Date] )

 

Best Regards,

Community Support Team _Janey

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

Nope, this doesn't work, soz.  It just returns the most recent Cust Last Booking Date from the entire table, and duplicates it down the column. 😞

 

I need the most recent Cust Last Booking Date for rows where the Parent Cust ID is the same, as per my example.

 

Sorry, I'm not sure how else to explain it.  Perhaps this extended example helps?

 

Cust IDCust Last Booking DateParent Cust IDParent Last Booking Date
123401/12/20999915/03/21
456715/03/21999915/03/21
987605/09/21

4789

05/09/21
567901/10/19478905/09/21
234506/07/21

1111

06/07/21
461305/09/20111106/07/21

 

I'm aiming to achieve the blue column data.

Hi @Anonymous 

 

That's why I asked you to share sample data...Your previous sample is incomplete.

Try this:

Last Booking Date =
MAXX (
    FILTER (
        ALL ( table ),
        [Parent Cust ID] = SELECTEDVALUE ( table[Parent Cust ID] )
    ),
    [Booking Date]
)

  

Best Regards,

Community Support Team _Janey

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

parry2k
Super User
Super User

@Anonymous Two ways to handle it:

 

- if you want to use PQ, keep all transformations in one table and use it as a reference.

- or best way is to use DAX measure, no additional tables will be required, just use one table with all the transformation and thru measure achieve the result. In the above example, just add a below measure and in table visual, put parent id and the measure, it should work

 

Last Booking Date = MAX ( Table[Booking Date] )

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



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.

Anonymous
Not applicable

Perfect, thank you.  😁  DAX is a much better way of course! 🙄

 

Ok, so next problem (sorry!).  I actually need to expose the MAX(Last Booking Date) across all Customer entities associated with the Parent Customer.  If I create a measure using Last Booking Date = MAX ( Table[Booking Date] ) then I get the Last Booking Date for the individual Customer in my report - which is at Customer Level.

 

This is what I'm after, i.e. the Parent Last Booking date is the MAX of all Booking Dates associated with child Customer entities.

 

Cust IDCust Last Booking DateParent Cust IDParent Last Booking Date
123401/12/20999915/03/21
456715/03/21999915/03/21

 

Thanks! 

Hi, @Anonymous 

 

So what should be the correct result?

vjaneygmsft_0-1646034347419.png

Can you share some sample data? So we can modify the code according to the field.

 

Janey

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.