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
Anonymous
Not applicable

Please help me in slicers

If I select 2017 then 2017-2019 should be selected and if i select 2018 than 2018 and 2019 to be selected and if 2019 only 2019 to be selected?

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

Hi @Anonymous ,

 

We can create a date table that is no relationship and a measure to meet your requirement.

 

1. Create a date table.

 

Date = ADDCOLUMNS(CALENDAR("2017/1/1","2019/12/31"),"year",YEAR([Date]))

 

p1.jpg

 

p2.jpg

 

2. Then we can create a measure,

 

measure = 
VAR _Select =
    SELECTEDVALUE ( 'Date'[year] )
RETURN
    IF (
        ISBLANK ( _Select ),
        CALCULATE ( SUM ( 'Table'[value] ) ),
        CALCULATE (
            SUM ( 'Table'[value] ),
            FILTER ( 'Table', 'Table'[year] >= _Select && 'Table'[year] <= _Select + 2 )
        )
    )

 

p3.jpg

 

p4.jpg

 

p5.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

6 REPLIES 6
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

How about the result after you follow the suggestions mentioned in my original post?

Could you please provide more details or expected result about it If it doesn't meet your requirement?

If you've fixed the issue on your own please kindly share your solution.

 

Best regards,

 

Community Support Team _ zhenbw

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

v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can create a date table that is no relationship and a measure to meet your requirement.

 

1. Create a date table.

 

Date = ADDCOLUMNS(CALENDAR("2017/1/1","2019/12/31"),"year",YEAR([Date]))

 

p1.jpg

 

p2.jpg

 

2. Then we can create a measure,

 

measure = 
VAR _Select =
    SELECTEDVALUE ( 'Date'[year] )
RETURN
    IF (
        ISBLANK ( _Select ),
        CALCULATE ( SUM ( 'Table'[value] ) ),
        CALCULATE (
            SUM ( 'Table'[value] ),
            FILTER ( 'Table', 'Table'[year] >= _Select && 'Table'[year] <= _Select + 2 )
        )
    )

 

p3.jpg

 

p4.jpg

 

p5.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

amitchandak
Super User
Super User

@Anonymous , You can not change slicer you can change the value in a measure

					
measure =
var _max = maxx(allselected(Date),Date[Year])
return
calculate(sum(Table[column]), filter(all(Date), Date[Year]>=_max && Date[Year]<=_max+2)) 					

@Anonymous Yes it can be achieved but you have to have a separate table for a slicer with uniques values for a year, let's assume this slicer table is called Slice Year with column Year, add the following measure and then use this measure for visual level filter

 

Filter Year = 
VAR __selectedYear = SELECTEDVALUE ( 'Slicer Year'[Year] ) 
RETURN
MAX ( YourTable[Year] ) - __selecteYear

 

In a visual level filter of the matrix put Filter Year measure and filter with greater than equal to zero and it would work.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous not sure wht you are trying to do, you want see the range of year based on selection or you want sum amount for ranges of year.

 

provide bit more context of your question. Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

sure, I have matrix below in columns I have the years and in rows I have products 

 

if from slicer i select 2017 the years from 2017 to 2019 should come in matrix

if from slicer i select 2018 the years from 2018 to 2019 should come in matrix

if from slicer i select 2019 than year 2019 should come in matrix

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.