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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
MindlessH
New Member

How to let the chart show the previous month data based on the slicer selection of the current month

Hello Everyone,

 

I am currently a new user to PowerBi and I have reached a dead-end with the charting. I am trying to build a chart same as the below one, where when I choose a period in the slicer, it shows the chosen month + the previous months data. If someone can kindly assist me with it.  I am looking at building the same chart as the below one. Thank you 

3A8F46A8-1816-4D1A-9CFD-AA7249940F30.png

1 ACCEPTED SOLUTION
v-yilong-msft
Community Support
Community Support

Hi @MindlessH ,

Please follow the below steps to achieve it:

1. Create a fiscal year months table as below.

vyilongmsft_0-1717727856756.png

2. Create a calculated column to get the fiscal month order.

Nmonthorder =
CALCULATE (
    MAX ( 'Fiscal year'[Order] ),
    FILTER ( 'Fiscal year', 'Fiscal year'[Fiscal Month] = 'Table'[Month] )
)

vyilongmsft_1-1717727937587.png

3. Create 4 measures as below to get the the corresponding value_1, value_2, value_3 and value_4 in previous selected month.

Nvalue_1 =
VAR _sfMonth =
    SELECTEDVALUE ( 'Fiscal year'[Fiscal Month] )
VAR sfmonthOrder =
    CALCULATE (
        SUM ( 'Fiscal year'[Order] ),
        FILTER ( 'Fiscal year', 'Fiscal year'[Fiscal Month] = _sfMonth )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value_1] ),
        FILTER ( 'Table', 'Table'[Nmonthorder] <= sfmonthOrder )
    )

Then you can select the month you want and get what you want.

vyilongmsft_2-1717728116371.png

 

 

 

Best Regards

Yilong Zhou

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

1 REPLY 1
v-yilong-msft
Community Support
Community Support

Hi @MindlessH ,

Please follow the below steps to achieve it:

1. Create a fiscal year months table as below.

vyilongmsft_0-1717727856756.png

2. Create a calculated column to get the fiscal month order.

Nmonthorder =
CALCULATE (
    MAX ( 'Fiscal year'[Order] ),
    FILTER ( 'Fiscal year', 'Fiscal year'[Fiscal Month] = 'Table'[Month] )
)

vyilongmsft_1-1717727937587.png

3. Create 4 measures as below to get the the corresponding value_1, value_2, value_3 and value_4 in previous selected month.

Nvalue_1 =
VAR _sfMonth =
    SELECTEDVALUE ( 'Fiscal year'[Fiscal Month] )
VAR sfmonthOrder =
    CALCULATE (
        SUM ( 'Fiscal year'[Order] ),
        FILTER ( 'Fiscal year', 'Fiscal year'[Fiscal Month] = _sfMonth )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value_1] ),
        FILTER ( 'Table', 'Table'[Nmonthorder] <= sfmonthOrder )
    )

Then you can select the month you want and get what you want.

vyilongmsft_2-1717728116371.png

 

 

 

Best Regards

Yilong Zhou

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

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 MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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