Forum Discussion

a0k08ac's avatar
a0k08ac
New Member
4 years ago
Solved

Dynamic Text Box based on 2 slicers

Hello,

I have 2 slicers and the I want the result text box in such a way that if I select the first slicer and don't select any option from the second slicer, the text should be based on only the selected first slicer option. Now comes the complicated part where if I keep the selected first slicer option and then also select an option from the second slicer, the text should only display the value of the second slicer.

 

Example -

Slicer 1 options -> A,B,C,D

Slicer 2 options -> P,Q,R,S

 

If I select slicer 1 option A and don't select anything from slicer 2, result should be A

If I keep the slicer 1 as A and also select for example Q from slicer 2, result should be Q

 

One thing to note is that the slicer 1 is connected to slicer 2 in such a way that whenever I select any option from slicer 1, options are filtered for slicer 2.

 

I am having a hard time to design a DAX formula for this.

 

Thanks!

  • Something like this should work:

    Text Measure =
    VAR varFirstSlicer =
        SELECTEDVALUE( Table[Field] )
    VAR varSecondSlicer =
        SELECTEDVALUE( Table[Field2] )
    VAR Result =
        IF(
            ISBLANK( varSecondSlicer ),
            varFirstSlicer,
            varSecondSlicer
        )
    RETURN
        Result
    

    If the second slicer has anything but 1 value selected, you'll get the first slicer value.

3 Replies

  • edhans's avatar
    edhans
    Community Champion

    Something like this should work:

    Text Measure =
    VAR varFirstSlicer =
        SELECTEDVALUE( Table[Field] )
    VAR varSecondSlicer =
        SELECTEDVALUE( Table[Field2] )
    VAR Result =
        IF(
            ISBLANK( varSecondSlicer ),
            varFirstSlicer,
            varSecondSlicer
        )
    RETURN
        Result
    

    If the second slicer has anything but 1 value selected, you'll get the first slicer value.

    • edhans's avatar
      edhans
      Community Champion

      Awesome. SELECTEDVALUE() is one of my favorite functions. If you have 1 value selected it returns it. If you have 2+ or none selected, it returns blank.