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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
JosephWu
Frequent Visitor

Slicer Setting limit the matrix?

Hi All,

I have touched the power BI almost 1month,and it's really funny and stimulate creativity by the DAX and matrix combined.

 

Recently,I just meet a problem,and solved that by YT Video and Blog.

A Business solution,
I need to show [Order].[Unit].[Revenue], filter by row[site] and column [Year].[Half Year].[Quarter].[Month]
If I select the 2022 Q3,my matrix will show 2022.Q3 /2022.Q2 and 2021/Q3 (this Quarter/Last Quarter/Last year with same Quarter)
and the 2022.Q3 table including QoQ YoY value 
(it could not show the other Quarter like 2022 Q1)
the final like this:

(Desktop)                                                                              (Report)
螢幕擷取畫面 2022-12-27 170304.png

螢幕擷取畫面 2022-12-27 165618.png

 

My slicer is YQ , created by Column with measure = year*10+Quarter([Date]) , type is whole number

and my value measure bulit by below with the swicth function 
螢幕擷取畫面 2022-12-27 171309.png

 

 

 

 

 

 

 

 

Fortunately,I got right answer,and this way also solved cross year problem(like 2022 Q1 /2021 Q4/ 2021 Q1)

 

But,I want to know! Is there ideal with dropdown slicer to solve this solution like below??
螢幕擷取畫面 2022-12-27 172454.png

 

 

 


 And,

Could I select the year slicer(2022) and Quarter slicer(Q3), the matrix will show 2021-Q3 and 2022-Q2/Q3 data?? 
Except for createing two calender table,Is there any way to do that?

Many question,
thanks for watch,
and I will appreciate the reply!

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

Hi  @JosephWu ,

I created some data:

vyangliumsft_0-1672217937087.png

If your slicer and matrix are related, then you select 2022.1.1 – 2022.2.1 in the slicer, only the date filtered by the slicer will appear between the matrices, if you want to display the date not selected in the slicer according to your own custom rules, you still need to have a date column that is not related to the data in the matrix.

After that, use the IF method to judge and put it in the filter to set.

1. Create measure.

Flag =
var _selectyear=SELECTEDVALUE('Year_Slicer'[Year])
var _selectqu=SELECTEDVALUE('Qu_Slicer'[Quarter])
return
IF(
AND(
YEAR(MAX('Table'[Date])) =_selectyear ,QUARTER(MAX('Table'[Date]))>=_selectqu-1&&QUARTER(MAX('Table'[Date]))<=_selectqu)
||
AND(
        YEAR(MAX('Table'[Date])) =_selectyear -1 ,QUARTER(MAX('Table'[Date]))=_selectqu),1,0)

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

vyangliumsft_1-1672217937089.png

3. Result:

vyangliumsft_2-1672217937094.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

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @JosephWu ,

I created some data:

vyangliumsft_0-1672217937087.png

If your slicer and matrix are related, then you select 2022.1.1 – 2022.2.1 in the slicer, only the date filtered by the slicer will appear between the matrices, if you want to display the date not selected in the slicer according to your own custom rules, you still need to have a date column that is not related to the data in the matrix.

After that, use the IF method to judge and put it in the filter to set.

1. Create measure.

Flag =
var _selectyear=SELECTEDVALUE('Year_Slicer'[Year])
var _selectqu=SELECTEDVALUE('Qu_Slicer'[Quarter])
return
IF(
AND(
YEAR(MAX('Table'[Date])) =_selectyear ,QUARTER(MAX('Table'[Date]))>=_selectqu-1&&QUARTER(MAX('Table'[Date]))<=_selectqu)
||
AND(
        YEAR(MAX('Table'[Date])) =_selectyear -1 ,QUARTER(MAX('Table'[Date]))=_selectqu),1,0)

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

vyangliumsft_1-1672217937089.png

3. Result:

vyangliumsft_2-1672217937094.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

Hi, @v-yangliu-msft

Thank your reply, it's helpful!
In normal or simple solution,I think I have gotten the correct way to solve that.
But I try to combine that in my solution,still having some problem.

My matrix use the Fact_sale table(Sum order) relationship with Dim_calender(Date By Date)
and I use the Dim_calender (4) being the slicer which single table NO Relationship from any table.
Matrix filter with this measure

#timeTest = 

var _selectyear=SELECTEDVALUE('DIM_Calendar (4)'[Year])
var _selectqu=SELECTEDVALUE('DIM_Calendar (4)'[QuarterNumber])

return
if(_selectqu -1 = 0,
if(
    AND( YEAR(MAX('DIM_Calendar'[Date])) =_selectyear -1 ,QUARTER(MAX('DIM_Calendar'[Date]))>=4||QUARTER(MAX('DIM_Calendar'[Date]))<=_selectqu)
||
AND(YEAR(MAX('DIM_Calendar'[Date])) =_selectyear,QUARTER(MAX('DIM_Calendar'[Date]))=_selectqu)    
    ,1,0
),if(AND( YEAR(MAX('DIM_Calendar'[Date])) =_selectyear ,QUARTER(MAX('DIM_Calendar'[Date]))>=_selectqu-1&&QUARTER(MAX('DIM_Calendar'[Date]))<=_selectqu)
||
AND(YEAR(MAX('DIM_Calendar'[Date])) =_selectyear -1 ,QUARTER(MAX('DIM_Calendar'[Date]))=_selectqu),1,0))

 

JosephWu_1-1672294543564.png


Untill now,all is right.
But I put the site(a column in Fact_sale),the filter is broken

JosephWu_2-1672294809134.png
I guess the problem caused by no relationship with the filter measure.
Should I add any relationship in the measure?

Regards,
Joseph



Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.