Forum Discussion

vbourbeau's avatar
vbourbeau
Resolver II
7 years ago

Use selectedvalue in a column

Hi,

I want to use a slicer for a sample table who are not linked to any other one. 

EX: table 1

Column1

Choice 1

Choice 2

Choice 3

 

In an other table I want to create a column who change dependent the value of the slicer.

I used selectedvalue like this:

column = if(selectedvalue(Table1[Column1]) = "Choice 1", true, false)

 

If I select in the slicer "Choice 1" The result are "False". 

 

If I create a measure with the same syntax it's work? But I need to populate a column not a measure.

 

How can I do that?

 

11 Replies

  • Hi vbourbeau ,

     

    You cannot make a calculated column value change according to the selection on a slicer, believe that you want to make this new column to present on a visual, so you need to make it with a measure.

     

    Measures are calculated based on context that can be given by a number of elements including the Slicer.

     

    Can you give a little more insight on how you want to use the result of the calculation so I can help you better.

     

    Regards,

    MFelix

    • vbourbeau's avatar
      vbourbeau
      Resolver II

      Ok look this example, it's what I'm tying to do. But in my real data I have more table to filter. So if I click on "last week" both table will filter for the last week result. I don't want to create new amount measure on each table because in reality I have 10 tables. 

      What I've trying it's create a column in the Date dimension who change value depending the slicer choice and add a page filter for that column.

      I put my example here https://we.tl/t-Q6hNDlJyXq

       

      • MFelix's avatar
        MFelix
        Super User

        Hi vbourbeau ,

         

        Looking at your model since you have the tables connect trough date table create the following measure:

         

        Filter Dates =
        SWITCH (
            TRUE ();
            SELECTEDVALUE ( 'Time'[Sequence] ) = 1; FILTER (
                SUMMARIZE ( Dates; Dates[Date] );
                Dates[Date] <= TODAY ()
                    && Dates[Date]
                        >= TODAY () - 7
            );
            SELECTEDVALUE ( 'Time'[Sequence] ) = 2; FILTER (
                SUMMARIZE ( Dates; Dates[Date] );
                Dates[Date] <= TODAY ()
                    && Dates[Date]
                        >= TODAY () - 84
            );
            SELECTEDVALUE ( 'Time'[Sequence] ) = 3; FILTER (
                SUMMARIZE ( Dates; Dates[Date] );
                Dates[Date] <= TODAY ()
                    && Dates[Date]
                        >= TODAY () - 365
            )
        )

        Then add this as a filter on your tables and select the option not blank final result will be the following:

         

         

        Check the PBIX file attach.

         

        Regards,

        MFelix