How to dynamically retrieve last months data

semidevil

New Member
Joined
Jul 9, 2007
Messages
35
I’m trying to create a bar chat that will always refresh to the previous month’s data, but keep the bar chart for previous year the same.

My bar chat will have 4 bars: 2015 bar, which will always display data for 201512(dec 2015), 2016 bar which will display 201612(dec 2016), 2017bar which for 201712(dec 2017), and a 2018 bar which will always change( so in February, it should automatically update to Jan 2018).

What would be the best way to start doing this?
 
Last edited:

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Something like this.

Code:
LastMonth = 
IF (
    MONTH ( TODAY () ) = 1,
    BLANK(),
    CALCULATE (
        [TotalValue],
        FILTER (
            Data,
            Data[Year] = YEAR ( TODAY() )
                && Data[Month] = MONTH( TODAY() ) - 1
        )
    )
)

and

Code:
Graph = 
IF (
    VALUES ( Data[Year] ) = YEAR ( TODAY () ),
    [LastMonth],
    [TotalValue]
)

Depending on the structure of your calendar table you might be able to simplify (ie if you had a unique month identifier column).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top