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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bourne2000
Helper V
Helper V

Showing last three months in the bar graph based on selecting month on the slicer?

Hi

 

I am having below table

 

bourne2000_0-1636323151906.png

 

I wanted to create a bar graph with month on the x-axis and value on the y axis. I need to create a month name filter and whenever I select single month, it show the last three months on the bar graph

 

For example, If I select April, the bar grapjh shows Jan, Feb, March and April

 

I tried to replicate the other posts solution, but no success. Can anyone advise please?

 

Sample PBIX file attached here https://we.tl/t-kWAov94QkZ

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

Hi @bourne2000 ,

I updated your sample pbix file(see attachment), please check whether that is what you want.

1. Delete the relationship between Date and Sheet1

yingyinr_1-1636527665637.png

2. Create a measure as below to get the sum of value

Measure = 
VAR _selyear =
    SELECTEDVALUE ( 'Date'[Year] )
VAR _selmonth =
    SELECTEDVALUE ( 'Date'[Month No] )
RETURN
    CALCULATE (
        SUM ( 'Sheet1'[Value] ),
        FILTER (
            'Sheet1',
            'Sheet1'[Year] = _selyear
                && 'Sheet1'[Month] >= _selmonth - 3
                && 'Sheet1'[Month] <= _selmonth
        )
    )

yingyinr_0-1636527610781.png

Best Regards

Community Support Team _ Rena
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
v-yiruan-msft
Community Support
Community Support

Hi @bourne2000 ,

I updated your sample pbix file(see attachment), please check whether that is what you want.

1. Delete the relationship between Date and Sheet1

yingyinr_1-1636527665637.png

2. Create a measure as below to get the sum of value

Measure = 
VAR _selyear =
    SELECTEDVALUE ( 'Date'[Year] )
VAR _selmonth =
    SELECTEDVALUE ( 'Date'[Month No] )
RETURN
    CALCULATE (
        SUM ( 'Sheet1'[Value] ),
        FILTER (
            'Sheet1',
            'Sheet1'[Year] = _selyear
                && 'Sheet1'[Month] >= _selmonth - 3
                && 'Sheet1'[Month] <= _selmonth
        )
    )

yingyinr_0-1636527610781.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

See if my solution here helps - Flex a Pivot Table to show data for x months ended a certain user defined month.

You may just import this workbook into PBI Desktop.  In PBI Desktop, just go to File > Import > Power Query, PowerPivot and PowerView.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
jdbuchanan71
Super User
Super User

@bourne2000 

Take a look at this article that discusses what you are trying to accomplish.

https://www.sqlbi.com/articles/show-previous-6-months-of-data-from-single-slicer-selection/

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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