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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
SairamMVV
New Member

Matrix Visual - How to show last 5 quarters in column based on slicer selection

Hi Team,

 

Good Day to you all!

 

I use a Matrix visual in my report with multiple Measures in the Values section, One dimension filed to Rows and Quarter filed to Columns.

 

Now the requirement is to limit the data to show for the last 5 quarters based on quarter selection.

Ex: if slicer is selected as Q1 2023, Matrix should show data from Q1 2022, Q2 2022, Q3 2022, Q4 2022 and Q1 2023

if else slicer is selected as Q2 2023, Matrix should show data from Q2 2022, Q3 2022, Q4 2022, Q1 2023 and Q2 2023.

 

Want to achieve this through Matrix visual only.

 

where as when i create measure like following 

 

Qtr_Selection =
VAR _Qtr = SELECTEDVALUE('Calendar'[Qtr_N]) -- Quarter number
VAR _Year = SELECTEDVALUE('Calendar'[Year]) -- Year number
VAR _YrQt = VALUE(_Year & _Qtr) -- Concatinating Year and Quarter (202201)
RETURN
IF( Value(MAX('Date'[Year]) & MAX('Date'[Qtr_N])) <= _YrQt && Value(MAX('Date'[Year]) & MAX('Date'[Qtr_N])) >= _YrQt-4,1,0)
 
When i use this measure in table format visual it is working as expected but not working for Maatrix visual.
 
Expected Matrix format:

SairamMVV_0-1692860163324.png

 

When above measure applied to fitlers section, this is how visual showing.

SairamMVV_1-1692860423249.png

 

any help will be appriciate and thanks in advance

 

Regards,

Sairam

 

@dax @PowerBIDESKTOP

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @SairamMVV 

 

You can try the following methods.
Date table:

vzhangti_0-1693297463273.png

Measure:

Rank YQ = RANKX(ALL('Date'),CALCULATE(MAX('Date'[YQ No.]),ALLEXCEPT('Date','Date'[YQ No.])),,ASC,Dense)

vzhangti_2-1693297516978.png

Slicer table:

Slicer table = VALUES('Date'[YQ No.])

vzhangti_3-1693297564757.png

Measure:

Measure = 
Var _rank1=CALCULATE([Rank YQ],FILTER(ALL('Date'),[YQ No.]=SELECTEDVALUE('Slicer table'[YQ No.])))
Var _rank2=_rank1-4
Return
IF(SELECTEDVALUE('Slicer table'[YQ No.])=BLANK(),1,IF([Rank YQ]>=_rank2&&[Rank YQ]<=_rank1,1,0))

vzhangti_4-1693297677126.png

Please refer to this method.

 

Best Regards,

Community Support Team _Charlotte

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-zhangti
Community Support
Community Support

Hi, @SairamMVV 

 

You can try the following methods.
Date table:

vzhangti_0-1693297463273.png

Measure:

Rank YQ = RANKX(ALL('Date'),CALCULATE(MAX('Date'[YQ No.]),ALLEXCEPT('Date','Date'[YQ No.])),,ASC,Dense)

vzhangti_2-1693297516978.png

Slicer table:

Slicer table = VALUES('Date'[YQ No.])

vzhangti_3-1693297564757.png

Measure:

Measure = 
Var _rank1=CALCULATE([Rank YQ],FILTER(ALL('Date'),[YQ No.]=SELECTEDVALUE('Slicer table'[YQ No.])))
Var _rank2=_rank1-4
Return
IF(SELECTEDVALUE('Slicer table'[YQ No.])=BLANK(),1,IF([Rank YQ]>=_rank2&&[Rank YQ]<=_rank1,1,0))

vzhangti_4-1693297677126.png

Please refer to this method.

 

Best Regards,

Community Support Team _Charlotte

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

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors