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
Love2phish
New Member

Showing Latest Data

Hello,

We have 5 different status we are tracking across our locations. We check one or 2 of those per month. Example shown here:

 

Location A StatusB StatusC StatusD StatusE StatusContact Date
Location 11  2 3/12/2024
Location 2555 33/15/2024
Location 2  3  4/1/2024
Location 3 5   4/6/2024
Location 142 324/10/2024

 

I would like to be able to show a table with a combined latest status for each location. For example based on the table above I would like to see the following output.

Location A StatusB StatusC StatusD StatusE StatusContact Date
Location 142 2 4/10/2024
Location 2553 24/1/2024
Location 3  5   4/6/2024
2 ACCEPTED SOLUTIONS
Sahir_Maharaj
Super User
Super User

Hello @Love2phish,

 

Can you please try this:

 

1. Find the most recent 'Contact Date' for each location

Latest Contact Date = 
CALCULATE(
    MAX('Table'[Contact Date]), 
    ALLEXCEPT('Table', 'Table'[Location])
)

2. For each status (A, B, C, D, E), create a measure to retrieve the latest non-blank status based on the latest contact date.

Latest A Status = 
CALCULATE(
    LASTNONBLANK('Table'[A Status], 'Table'[A Status]),
    'Table'[Contact Date] = [Latest Contact Date],
    ALLEXCEPT('Table', 'Table'[Location])
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

lbendlin
Super User
Super User

You may want to consider unpivoting your data. 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8slPTizJzM9TMFTSUQJhBSg2gtLG+oZG+kYGRiZKsTpIykHSpkgYrBSi3BSHcgUkZTC2ib4hFtUwFaZIKiGqzbCoBrnaBNnFUDbQbAOo8lgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Location " = _t, #"A Status" = _t, #"B Status" = _t, #"C Status" = _t, #"D Status" = _t, #"E Status" = _t, #"Contact Date" = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Location ", "Contact Date"}, "Status ID", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] <> " ")),
    #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"Contact Date", type date}})
in
    #"Changed Type"

 

Then you can create a cross join between locations and status IDs

 

Table 2 = CROSSJOIN(values('Table'[Location ]),values('Table'[Status ID]))
 
Then you can calculate the latest status for each combination
 
lbendlin_0-1713042345439.png

 

Note that I (ab)used the column total for the "Last contact date".

 

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

You may want to consider unpivoting your data. 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8slPTizJzM9TMFTSUQJhBSg2gtLG+oZG+kYGRiZKsTpIykHSpkgYrBSi3BSHcgUkZTC2ib4hFtUwFaZIKiGqzbCoBrnaBNnFUDbQbAOo8lgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Location " = _t, #"A Status" = _t, #"B Status" = _t, #"C Status" = _t, #"D Status" = _t, #"E Status" = _t, #"Contact Date" = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Location ", "Contact Date"}, "Status ID", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Value] <> " ")),
    #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"Contact Date", type date}})
in
    #"Changed Type"

 

Then you can create a cross join between locations and status IDs

 

Table 2 = CROSSJOIN(values('Table'[Location ]),values('Table'[Status ID]))
 
Then you can calculate the latest status for each combination
 
lbendlin_0-1713042345439.png

 

Note that I (ab)used the column total for the "Last contact date".

 

Sahir_Maharaj
Super User
Super User

Hello @Love2phish,

 

Can you please try this:

 

1. Find the most recent 'Contact Date' for each location

Latest Contact Date = 
CALCULATE(
    MAX('Table'[Contact Date]), 
    ALLEXCEPT('Table', 'Table'[Location])
)

2. For each status (A, B, C, D, E), create a measure to retrieve the latest non-blank status based on the latest contact date.

Latest A Status = 
CALCULATE(
    LASTNONBLANK('Table'[A Status], 'Table'[A Status]),
    'Table'[Contact Date] = [Latest Contact Date],
    ALLEXCEPT('Table', 'Table'[Location])
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Thank you this solved it for me.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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