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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
dinesharivalaga
Post Patron
Post Patron

Display last 3 months data in stacked bar chart

Hi All ,

As per business requirement i need to display last 3 months data as a stacked bar chart (because i am using region wise data as a legend) .I have data until May23 , so in the visual i need to showcase only Mar,April,May data only .

Using year slicer as well .. if i select 2022 , then the visual should give Oct,Nov and Dec data as per requirement .

I have data like below only .

MonthYearVolumeValue (Func. Currency)
APR2023                                   1.38
APR2023                                   6.60
FEB2023                                   1.30
FEB2023                                   3.47
JAN2023                                   1.05
JAN2023                                   2.64
MAR2023                                   1.61
MAR2023                                   2.84

currently it is showing all 4 months as i am selected 2023 in year slicer .

Please help to fix this asap ?

 

thanks in advance

dinesh

3 REPLIES 3
Anonymous
Not applicable

Hi  @dinesharivalaga ,

Here are the steps you can follow:

1. Create calculated table.

vyangliumsft_0-1687154737132.png

2. Create measure.

Flag =
var _select=
SELECTEDVALUE('Table 2'[Year])
var _column=
SELECTCOLUMNS(
    FILTER(ALL('Table'),
    'Table'[Year]=_select),"Month",[Month])
var _maxdate=
MAXX(
   FILTER(ALL('Table 2'),
    'Table 2'[Year]=_select&&'Table 2'[Month] in _column),[Date])
var _mindate=
EOMONTH(
    _maxdate,-3)+1
var _include=
SELECTCOLUMNS(
    FILTER(ALL('Table 2'),
    'Table 2'[Date]>=_mindate&&'Table 2'[Date]<=_maxdate),"1",[Month])
return
IF(
    MAX('Table'[Year])=_select&&MAX('Table'[Month]) in _include,1,0)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1687154737135.png

4. Result:

vyangliumsft_2-1687154782485.png

 

Best Regards,

Liu Yang

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

@Anonymous thanks for your response ..

I have created the flag in my dashboard and applied the same but i got below error popup once flag filter applied ..

dinesharivalaga_0-1687507802349.png

Please advise on this ?

some_bih
Super User
Super User

Hi  @dinesharivalaga check Relative date type of fitler. I hope this help 

 

some_bih_0-1686923785111.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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