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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
schaezac
Frequent Visitor

Show latest value based on date and other criteria (measure or new column)

Hi,

 

I am trying to create a measure or column that will allow me to easily bring the latest value into my visuals. Here is some example data; the highlighted column is what I'm trying to create.

 

schaezac_0-1741725149350.png

 

The end goal is to show the most recent sale as a flat line across a graph, so I can compare historical sales to the most recent one visually, by product. Also, the date needs to be dynamic so it automatically updates the values when fresh data is loaded.

 

Thanks!

1 ACCEPTED SOLUTION
techies
Resolver III
Resolver III

Hi @schaezac please check this

 

MostRecentSalePerProduct =
VAR LatestDateForProduct =
    CALCULATE(
        MAX('Sheet2'[Date]),
        ALLEXCEPT('Sheet2', 'Sheet2'[Product])
    )
RETURN
CALCULATE(
    MAX('Sheet2'[Sale]),
    ALLEXCEPT('Sheet2', 'Sheet2'[Product]),
    'Sheet2'[Date] = LatestDateForProduct
)

View solution in original post

2 REPLIES 2
techies
Resolver III
Resolver III

Hi @schaezac please check this

 

MostRecentSalePerProduct =
VAR LatestDateForProduct =
    CALCULATE(
        MAX('Sheet2'[Date]),
        ALLEXCEPT('Sheet2', 'Sheet2'[Product])
    )
RETURN
CALCULATE(
    MAX('Sheet2'[Sale]),
    ALLEXCEPT('Sheet2', 'Sheet2'[Product]),
    'Sheet2'[Date] = LatestDateForProduct
)

EDIT: please disregard follow up - fixed my date table range to correct this. Thanks again, you're a lifesaver!

 

This worked - thanks so much! One last question - is there a way to curtail the data so it does not extend past my most recent data? For example, in the graph below, my most recent data is in January 2025. I would like the dotted line (the one you helped me create) to stop in January as well. I think this is due to my date table extending far beyond the latest actual data.

 

schaezac_0-1741784668711.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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