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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Krutigawale33
Responsive Resident
Responsive Resident

Slicer

Hello All,

May be silmilar thing I have posted earlier. I have requirement to create slicer which are having two fields:-

1)Fiscal YTD

2)Rolling 12 Months

 

When enduser select "Fiscal YTD" the graph should show the months on x-axis till date/selected Month.

when end user select "Rolling 12 Months". the x-axis should show months 12 months rolling/Back from current/selected month.

 

The page is also having another slicer on Fiscal month to selected the month.

Fiscal month is column from Table.

 

How to implement slicer with two above fields to work accordingly.

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

Hi @Krutigawale33 ,


According to your description, you could create two tables as slicers, then create a flag measure and apply it into filter. the following formula to create :

Step1: Enter slicer1 table

 

Forslicer1 = DISTINCT(SELECTCOLUMNS('W_MCAL_PERIOD_D',"month",[MCAL_PER_NAME_MNTH]))

 

v-yalanwu-msft_0-1619673847572.jpeg

Step2: Enter slicer1 table

v-yalanwu-msft_1-1619673853551.png

Step3: Create a flag measure

 

flag =
VAR _sele =
MAX ( 'Forslicer1'[month] )
VAR _date =
DATE ( RIGHT ( _sele, 4 ), MONTH ( LEFT ( _sele, 3 ) & " 1" ), 1 )
VAR _actual =
MAX ( 'W_MCAL_PERIOD_D'[MCAL_PER_NAME_MNTH] )
VAR _actualDate =
DATE ( RIGHT ( _actual, 4 ), IF ( _actual <> BLANK (), MONTH ( LEFT ( _actual, 3 ) & " 1" ) ), 1 )
VAR _datediff =
DATEDIFF ( _date, _actualDate, MONTH )
RETURN
SWITCH (
SELECTEDVALUE ( 'Forslicer2'[Slicer] ),
"Fiscal YTD",
IF (
RIGHT ( _actual, 4 ) = SELECTEDVALUE ( 'Forslicer1'[Year] )
&& _actualDate <= _date,
1,
0
),
"Rolling 12 Months",
IF ( _datediff <= 12 && _datediff >= 0, 1, 0 )
)

 

Step4: Apply the flag measure into filter

v-yalanwu-msft_2-1619673873908.jpeg

 

Step5: the final output is shown below

v-yalanwu-msft_3-1619673878938.jpegv-yalanwu-msft_4-1619673890464.jpeg


Best Regards,
Community Support Team_ Yalan Wu
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

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi @Krutigawale33 ,


According to your description, you could create two tables as slicers, then create a flag measure and apply it into filter. the following formula to create :

Step1: Enter slicer1 table

 

Forslicer1 = DISTINCT(SELECTCOLUMNS('W_MCAL_PERIOD_D',"month",[MCAL_PER_NAME_MNTH]))

 

v-yalanwu-msft_0-1619673847572.jpeg

Step2: Enter slicer1 table

v-yalanwu-msft_1-1619673853551.png

Step3: Create a flag measure

 

flag =
VAR _sele =
MAX ( 'Forslicer1'[month] )
VAR _date =
DATE ( RIGHT ( _sele, 4 ), MONTH ( LEFT ( _sele, 3 ) & " 1" ), 1 )
VAR _actual =
MAX ( 'W_MCAL_PERIOD_D'[MCAL_PER_NAME_MNTH] )
VAR _actualDate =
DATE ( RIGHT ( _actual, 4 ), IF ( _actual <> BLANK (), MONTH ( LEFT ( _actual, 3 ) & " 1" ) ), 1 )
VAR _datediff =
DATEDIFF ( _date, _actualDate, MONTH )
RETURN
SWITCH (
SELECTEDVALUE ( 'Forslicer2'[Slicer] ),
"Fiscal YTD",
IF (
RIGHT ( _actual, 4 ) = SELECTEDVALUE ( 'Forslicer1'[Year] )
&& _actualDate <= _date,
1,
0
),
"Rolling 12 Months",
IF ( _datediff <= 12 && _datediff >= 0, 1, 0 )
)

 

Step4: Apply the flag measure into filter

v-yalanwu-msft_2-1619673873908.jpeg

 

Step5: the final output is shown below

v-yalanwu-msft_3-1619673878938.jpegv-yalanwu-msft_4-1619673890464.jpeg


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HarishKM
Impactful Individual
Impactful Individual

@Krutigawale33 Hey 

Create a disconnected table then drag that value to a slicer .

you can use swtich function .

 

test = switch( true(),
 selectedvalue([tablename[name]) = "Fiscal YTD",[Fiscal YTD],
selectedvalue([tablename[name]) = "Rolling 12 Months",[Rolling 12 Months],
,[Rolling 12 Months],)

then drag that measure to your chart and matrix .

whenever you make slicer selection as fy ytd then it will fy ytd only .

 

 

Thanks @amitchandak 

I have tried with what you suggested but no luck

 

I am sharing my powerBI file https://drive.google.com/file/d/1gb6VTwCaBeOPxuZUqukmhS8dgZAXHBC9/view?usp=sharing 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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