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

DAX to fetch values from two slicers on same column

Hi,

I have have a column with quarters and year in the format "2019/Q3".

I want to have 2 different slicers on this column so that i can compare results across these 2 quarters selected.

The hurdle for me is fetch individual values from these 2 slicers. I tried using selectedvalue but it does not work. It would be great if someone can help me here.

e.g if selected value in slicer 1 is "2019/Q3" and selected value in slicer 2 is "2019/Q4", then i need 2 measures with these 2 values as result.

Note: the slicers are based on the same column in a table

 

Thank you.

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous,

When making more tahn one slicer on the sam column you will get the information from tue slicers filtered by the selection of the others since the slicers work for filtering the data so you will get subsets of your data.

Based on your requirement you ca do one of two things:

Create a single slicer that allows you to select more than 1 value and then using the MAX and MIN function get the highest and lowest value on the slicer and use those for your measures. Be aware that you would probably also need to add a measure to warn when user selects more than two values.

Other option is to create two separet tables fo the slicers (without relationship) to the the column you need to filter and then using th selecred value for eaxh of the slicers create you measures.

Regard,
MFelix

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

4 REPLIES 4
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

You need to create new irrelevant tables as slicers. If use the original column, the results will be always filtering by another slicer.I create a sample that you could have a try.

  • Create a column in original table
Year & Quarter = 'Table'[Date].[Year]&"/Q"&'Table'[Date].[QuarterNo]
  •  Create two new tables

1.PNG

  • Create two measures
Q3 = 
VAR a =
    SELECTEDVALUE ( '2019/Q3'[2019/Q3] )
VAR b =
    CALCULATE (
        SUM ( 'Table'[ Sales] ),
        FILTER ( 'Table', 'Table'[Year & Quarter] = a )
    )
RETURN
    IF ( ISFILTERED ( '2019/Q3'[2019/Q3] ), b, BLANK () )

Q4 = 
VAR a =
    SELECTEDVALUE ( '2019/Q4'[2019/Q4] )
VAR b =
    CALCULATE (
        SUM ( 'Table'[ Sales] ),
        FILTER ( 'Table', 'Table'[Year & Quarter] = a )
    )
RETURN
    IF ( ISFILTERED ( '2019/Q4'[2019/Q4] ), b, BLANK () )

2.PNG3.PNG

Best Regards,

Xue Ding

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

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MFelix
Super User
Super User

Hi @Anonymous,

When making more tahn one slicer on the sam column you will get the information from tue slicers filtered by the selection of the others since the slicers work for filtering the data so you will get subsets of your data.

Based on your requirement you ca do one of two things:

Create a single slicer that allows you to select more than 1 value and then using the MAX and MIN function get the highest and lowest value on the slicer and use those for your measures. Be aware that you would probably also need to add a measure to warn when user selects more than two values.

Other option is to create two separet tables fo the slicers (without relationship) to the the column you need to filter and then using th selecred value for eaxh of the slicers create you measures.

Regard,
MFelix

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



mussaenda
Community Champion
Community Champion

I suggest you to turn on the interaction of the slicers for the desired tables only.

You can see the edit interactions on Format Tab once you clicked the slicer tab

Anonymous
Not applicable

Thanks, but I don't want to display them as visuals. I need those 2 values as 2 separate measures as I will be using them to calculate some other metrics in the report.

Helpful resources

Announcements
March Fabric Community Update

Fabric Community Update - March 2024

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

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.

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.