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
unnijoy
Post Partisan
Post Partisan

Display last 4 quarter name and its sum in matrix table based on selected month

I have a data set with Month, Country, Total Sales, Quarter

My quarter is customised one. Dec - Feb (Qtr1), Mar - May(Q2), Jun - Aug (Q3), Sep - Nov (Q4).

I need to show total sales for last 4 quarter based on the selectde month in a matrix table.

For example if i select May-2023 in the slicer then it show show as below 

unnijoy_0-1686767563762.png

May-2023 belong to Q2-23 and the last 4 Quarter. 

Basically what i need is that Quarter name in the Matrix table show change based on the month that i select in the slicer.
And we are setting the slicer to Singe select.

 

Please help me to solve this.

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

What if you select a month which falls in between a quater such as January.  Then do you want to compare 2 months of the current quarter with all 3 months of the previous 3 quarters?

Share data in a fomat that can be pasted in an MS Excel file.  


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi  @unnijoy ,

I created some data:

vyangliumsft_0-1686885237001.png

Here are the steps you can follow:

1. Create calculated column.

Table 2 =
DISTINCT('Table'[year_month])

vyangliumsft_1-1686885237002.png

2. Create measure.

Measure =
var _select=SELECTEDVALUE('Table 2'[year_month])
var _max=MAXX(FILTER(ALL('Table'),'Table'[year_month]=_select),[Quarter_Month])
var _maxdate=MAXX(FILTER(ALL('Table'),'Table'[Quarter_Month]=_max),[Date])
var _last12=EOMONTH(_maxdate,-12)+1
return
IF(
   MAX( 'Table'[Date]) >= _last12 && MAX('Table'[Date]) <= _maxdate,
    SUMX(
        FILTER(ALL('Table'),        'Table'[Country]=MAX('Table'[Country])&&'Table'[Quarter_Month]=MAX('Table'[Quarter_Month])),[Value]),BLANK())

3. Result:

vyangliumsft_2-1686885273013.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 ,

 

The above measure is helping me to solve ma Qtr display. But when i try to show the sales for that selected month its is not wokring. how can i fix that. I mean as per the above set up when i set May-2023 it should show the above table and on the other side i need to show country wise sales for that selected month. 
the how can i show that.
I have a calende table and country table seperatly. and am taking date from caleneder table and Country from Country table.

hi @Anonymous  can you pls help me with the above

 

Ahmedx
Super User
Super User

could you share your pbix-file? Or create an example file which reproduces your issue?

Helpful resources

Announcements
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.