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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Filtering results on X Axis

Hi,

 

New to PowerBI so apologies if this should be obvious.

 

If I have the following data:

Fiscal YQ table

 

YQrownum
2020 Q 4        1
2020 Q 3        2
2020 Q 2        3
2020 Q 1        4
2019 Q 4        5
2019 Q 3        6
2019 Q 2        7
2019 Q 1        8

 

Then another table

YQRepNet Amount USD
2020 Q 4John Smith200
2020 Q 3Jane Doe500
2019 Q 4John Smith400

 

And I have a slicer on the YQ item, how would I ensure that:

A stacked bar chart only shows x numbers of items on the x axis.  Specifically, I wanted to show a max of last 4 quarters in the past if nothing is filtered (I have multiple years of data, the chart gets crowded, but I don't want to filter this information out as people may want to review items 3 years in the past).

 

I had created a measure:

QuarterSelectBounds = ((CALCULATE(MIN('AnalysisFiscalYearQuarterSort'[rownum]),ALLSELECTED(AnalysisFiscalYearQuarterSort[rownum]))+3))
 
and then another measure
Net Amount USD QuarterSelectBounded = IF(MIN('AnalysisFiscalYearQuarterSort'[rownum]) <= [QuarterSelectBounds], sum('Bookings'[Net Amount USD]), BLANK())
 
This works great, but only if I am using rownum on the x axis.  As soon as I swap it out to the YQ value, the min is applied on the line level.  I have done a lot of reading and feel like I might need to create some sort of disconnected table, but I'm a little lost at this point.  Any help?
 
Thanks
1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

If you want this to work for all YQ then you need to use YQ in the ALLSELECTED:

QuarterSelectBounds = ((CALCULATE(MIN('AnalysisFiscalYearQuarterSort'[rownum]),ALLSELECTED(AnalysisFiscalYearQuarterSort[YQ]))+3))

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Create a common qtr year table, join with both table . Create a Qtr year rank in that on year qtr

 

new column
Qtr Rank = RANKX(all('Date'),'Date'[Qtr Start date],,ASC,Dense)

 

measure
This Qtr = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank])))
Last Qtr = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank])-1))

 

last 4 Qtr = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'), 'Date'[Qtr Rank]>=max('Date'[Qtr Rank])-4 && 'Date'[Qtr Rank]<=max('Date'[Qtr Rank])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
AllisonKennedy
Super User
Super User

If you want this to work for all YQ then you need to use YQ in the ALLSELECTED:

QuarterSelectBounds = ((CALCULATE(MIN('AnalysisFiscalYearQuarterSort'[rownum]),ALLSELECTED(AnalysisFiscalYearQuarterSort[YQ]))+3))

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.