Forum Discussion

IF's avatar
IF
Post Prodigy
5 years ago
Solved

SELECTEDVALUE with Slicer Selection

Hi,

have the following data:

Slider1

Slider2

Date

Value

DateFormated

#

A

07.2020

12

1/7/2020

#

B

07.2020

14

1/7/2020

C1

A

07.2020

21

1/7/2020

C2

A

07.2020

23

1/7/2020

D1

B

07.2020

32

1/7/2020

D2

B

07.2020

34

1/7/2020

#

A

08.2020

42

1/8/2020

#

B

08.2020

44

1/8/2020

C1

A

08.2020

55

1/8/2020

C2

A

08.2020

35

1/8/2020

D1

B

08.2020

46

1/8/2020

D2

B

08.2020

65

1/8/2020

#

A

11.2019

77

1/11/2019

#

B

11.2019

76

1/11/2019

C1

A

11.2019

54

1/11/2019

C2

A

11.2019

66

1/11/2019

D1

B

11.2019

56

1/11/2019

D2

B

11.2019

67

1/11/2019

 

I use the measure: ValueMeasure = CALCULATE(SUM('Table'[Value]),'Table'[Slider1]="#")

If I select A or B value at slider2, I get the right result.

 

However, I get wrong result if I select slicer1 value. For example I should get 55, but it shows 86. So I want to have a better measure that works for both slicers.

 

 

I hope it is clearly explained.

Thanks in advance!

  • Hi IF

    Ok, I didn't understand you well last time.
    You have two solutions:
    1. Create one additional Slider column based on slider1 and slider2. (If slider1 = #, take slider2, otherwise slider1).
    Add a new column as a slider and use it for filtering.

    2. Create a measure:

    ValueMeasure = 
    VAR _slider1 = SELECTEDVALUE('Table'[Slider1])
    
    RETURN
    IF(ISFILTERED('Table'[Slider1]),
    CALCULATE(Sum('Table'[Value]), All('Table'[Slider2])),
    CALCULATE(Sum('Table'[Value]), FILTER('Table', 'Table'[Slider1] = "#"))
    )

     



    _______________
    If I helped, please accept the solution and give kudos! 😀

14 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    IF I mocked this up in a PBIX, can you confirm that I did it correctly? Your measure is going to calculate the SUM for # rows always the way it is written.  See PBIX below sig. It is odd that the slicer does not seem to be impacting the card visual though.

     

    • IF's avatar
      IF
      Post Prodigy

      Hi,

      Thanks for the support. However, this is not working. It shows the same value if I select C1, C2, etc.

      All the best

      Ismail

    • IF's avatar
      IF
      Post Prodigy

      Hi, It is not working for slicer one 😞

  • lkalawski's avatar
    lkalawski
    Resident Rockstar

    Hi IF

    Why do you use the condition 'Table' [Slider1] = "#" in the measure? 

    When using such a condition, you cannot use Slicer1 because the measure will always calculate for "#".
    If you want to dynamically change slicers and show the total, you just need to create a measure SUM ('Table' [Value]) and the values will change dynamically.

    Examples:

     

    If you want to include the date as well as a filter, add another slicer or add condition to the measure.



    _______________
    If I helped, please accept the solution and give kudos! 😀

     

     
    • IF's avatar
      IF
      Post Prodigy

      Hi,

      If I delete the part: Table'[Slider1]="#" then, I don't get result for other slicer.

       
      All the best
  • I have created slicers from a table of measures. 

     

    I need help with my selected measureshowing the data rather than the name, is this possible?

     

    i want the card showing Age 31-35 to show the value e.g. 35 instead of the name of the measure. 

     

    thank you

    • IF's avatar
      IF
      Post Prodigy

      I would do another column and replace the data. In this case I would replace "Age 31-35" with "35". You can also change the column for the slicer to display the new column.