cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Show Last Available Value in Timeline Report

Hi all, 

 

Let's say I have inventory table with the following data:

Jan 2017: 10

Feb 2017: 20

Mar 2017: 30

 

and then I want to create a Date by Inventory Quantity matrix/bar chart that continues to populate the numbers from Apr 2017 onwards with the last available inventory value (i.e. 30, from Mar 2017). The expected output is as follows:

 

Jan 2017: 10

Feb 2017: 20

Mar 2017: 30

Apr 2017: 30

...

Nov 2017: 30

Dec 2017: 30

 

How do I write the DAX measure? I've tried the following but it doesn't work.

 

Max PInv Value = 
IF(ISBLANK(SUM(InventoryPartial[PInvQuantity]))=FALSE(), 
    SUM(InventoryPartial[PInvQuantity]),
   CALCULATE(SUM(InventoryPartial[PInvQuantity]), FILTER(all(InventoryPartial), InventoryPartial[Date] = MAX(InventoryPartial[Date]))))

 

Here's a link to the sample file. Please use the InventoryPartial table. 

 

Thank you!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resident Rockstar
Resident Rockstar

Re: Show Last Available Value in Timeline Report

Hi @johnconnor92,

 

You could try this measure below.

 

Max PInv Value =
VAR vdate =
    CALCULATE (
        LASTNONBLANK ( 'InventoryPartial'[Date], MAX ( 'InventoryPartial'[Date] ) ),
        ALL ( DateTable )
    )
RETURN
    IF (
        ISBLANK ( SUM ( InventoryPartial[PInvQuantity] ) ) = FALSE (),
        SUM ( InventoryPartial[PInvQuantity] ),
        CALCULATE (
            SUM ( InventoryPartial[PInvQuantity] ),
            FILTER (
                ALL ( InventoryPartial ),
                MONTH ( InventoryPartial[Date] ) = MONTH ( vdate )
            )
        )
    )

And the output is below.

 

Capture.PNG

 

Hope it can help you!

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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

3 REPLIES 3
Highlighted
Resident Rockstar
Resident Rockstar

Re: Show Last Available Value in Timeline Report

Hi @johnconnor92,

 

You could try this measure below.

 

Max PInv Value =
VAR vdate =
    CALCULATE (
        LASTNONBLANK ( 'InventoryPartial'[Date], MAX ( 'InventoryPartial'[Date] ) ),
        ALL ( DateTable )
    )
RETURN
    IF (
        ISBLANK ( SUM ( InventoryPartial[PInvQuantity] ) ) = FALSE (),
        SUM ( InventoryPartial[PInvQuantity] ),
        CALCULATE (
            SUM ( InventoryPartial[PInvQuantity] ),
            FILTER (
                ALL ( InventoryPartial ),
                MONTH ( InventoryPartial[Date] ) = MONTH ( vdate )
            )
        )
    )

And the output is below.

 

Capture.PNG

 

Hope it can help you!

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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

Highlighted
Helper II
Helper II

Re: Show Last Available Value in Timeline Report

Thank you @v-piga-msft Cherry!

Highlighted
Helper II
Helper II

Re: Show Last Available Value in Timeline Report

Hi Cherry @v-piga-msft, do you mind explaining the formula? The LASTNONBLANK variable really tripped me off, I wouldn't have thought of it. (I'm still relatively new to DAX).

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Upcoming Events

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors