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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Need to find a latest value for Unit across Dates

Hi guys, I have data similar to below table where I need to create a measure to get the latest Unit Size for a given Unit Number (Unit 1, Unit2, Unit3) across the dates and output should be according to the results as highlighted below. Please can someone help me with the DAX command.

Sample Data:
              01-01-20      02-01-20     03-01-20
              Unit Size       Unit Size      Unit Size
Unit 1     25                15
Unit 2     50                40
Unit 3     10

 

ranjanrkl_0-1632936503912.png

 

 

 

 

5 REPLIES 5
ERD
Community Champion
Community Champion

@Anonymous ,

I'd suggest you to first prepare your data in Power Query:

ERD_0-1632934768920.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WOrRASUcpNC+zRCE4syqVAC9WJxrCNwRKGJnCCIS4EZBnagAkzAxQxI2BPEOQENhIpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"01-01-20" = _t, #"02-01-20 " = _t, #"03-01-20" = _t]),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {"(blank)"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns", each ([#"(blank)"] <> " ")),
    #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"Value", type number}}),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Changed Type", {{"Attribute", type date}}, "en-CH")
in
    #"Changed Type with Locale"

 

Then you can try this measure:

 

latestValue = 
VAR latestDate = MAXX ( FILTER ( 'Table', 'Table'[Value] <> BLANK () ), 'Table'[Date] )
RETURN
    CALCULATE ( MAX ( 'Table'[Value] ), 'Table'[Date] = latestDate )

 

ERD_0-1632935421087.png

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

 

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Anonymous
Not applicable

Thanks @ERD .

The following DAX will return the MAX of the Unit Size right? Ex- For Unit 2 and date - 02-01-20, its giving 60.
What I need is the Latest value, if for same Unit 2, the Unit Size is 40 on date - 02-01-20 then Latest Unit Size in Unit 2 should return 40.

Anonymous
Not applicable

@ERD , I have updated the post and sample data to be clear on the requirements.

ERD
Community Champion
Community Champion

@Anonymous ,

the code will return the latest value, not the biggest one:

ERD_1-1632980900016.png

 

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

ERD
Community Champion
Community Champion

@Anonymous ,

Please, provide sample data as text, use the table tool in the editing bar.

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

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.