Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Dynamic column based on slicer selection

Hi 

I have a list of company names and their blinded company names as below.

If i put the name in slicer and selected a value(let it be "ABC").
The output in the column should be 


Please help me to create a dynamic column that changes based on slicer selction.

Thanks,
Mahesh R



8 Replies

  • Hi, Anonymous 

    I am not sure whether I understood your question correctly, but please check the below picture and the sample pbix file.

    I hid the very first column on the left side of the table visualization (red color area), and tried to only show the Outcome Column on the visualization.

     

     

    Output =
    VAR selectedname =
    ALLSELECTED ( 'Company Names'[Name] )
    RETURN
    IF (
    HASONEVALUE ( 'Company Names'[Name] ),
    IF (
    SELECTEDVALUE ( 'Blinded Names'[Name] ) IN selectedname,
    SELECTEDVALUE ( 'Blinded Names'[Name] ),
    SELECTEDVALUE ( 'Blinded Names'[Blinded Name] )
    ),
    SELECTEDVALUE ( 'Blinded Names'[Blinded Name] )
    )
     
     

    Hi, My name is Jihwan Kim.


    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


    Linkedin: linkedin.com/in/jihwankim1975/

    Twitter: twitter.com/Jihwan_JHKIM

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Jihwan_Kim 

      The Output is coming as expectd only but the issue is I need a column with this similar functionality.
      So that i can use that conditional colum in the column of the stacket chart.

      Thanks
      Mahesh R

      • Jihwan_Kim's avatar
        Jihwan_Kim
        Super User

        Hi, Anonymous 

        Thank you for your feedback.

        At this moment, the only way that I can think of is to create a new table like below.

        Please check the below picture and the sample pbix file's link down below.

         

         

        I created a new table in two steps.

         

        New Table =
        CROSSJOIN (
        VALUES ( 'Blinded Names'[Name] ),
        VALUES ( 'Blinded Names'[Blinded Name] )
        )
         
         
        New Column =
        IF (
        LOOKUPVALUE (
        'Blinded Names'[Blinded Name],
        'Blinded Names'[Name], 'New Table'[Name]
        ) = 'New Table'[Blinded Name],
        'New Table'[Name],
        'New Table'[Blinded Name]
        )
         
         
         
         

        Hi, My name is Jihwan Kim.


        If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


        Linkedin: linkedin.com/in/jihwankim1975/

        Twitter: twitter.com/Jihwan_JHKIM

  • v-luwang-msft's avatar
    v-luwang-msft
    Community Support

    Hi Anonymous ,

    You could use the following measure:

    Output =
    VAR test1 =
        CONCATENATEX ( VALUES ( 'Slicer'[name] ), [Name], "," )
    VAR test3 =
        MAX ( 'Table'[Name] )
    VAR test2 =
        SEARCH ( test3, test1,, 0 )
    VAR test4 =
        IF ( test2 > 0, MAX ( 'Table'[Name] ), MAX ( 'Table'[Blinden Name] ) )
    RETURN
        test4

     

    Final get the below:

    If you choose one value:

     

    If you choose multiple  values:

    You could download my pbix file if you need!

     

    Best Regards

    Lucien

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi v-luwang-msft 

      You created a measure to get the expected output where i need the same funtionality in Column.
      So that i can use this in column of stacked chart.

      Thanks 
      Mahesh R

  • v-luwang-msft's avatar
    v-luwang-msft
    Community Support

    Hi Anonymous ,

    Calculated columns are calculated only ONCE, AT REFRESH.  They do not change in response to measures, or slicer selections.

    The only way  just as Jihwan_Kim  mentioned.

    This method can achieve the results you expect, but it does have the disadvantage of not being able to select multiple values.

    Best Regards

    Lucien

     

  • v-luwang-msft's avatar
    v-luwang-msft
    Community Support

    Hi Anonymous ,

    Has your problem been solved, if so, please consider Accept a correct reply as the solution to help others find it.
     
    Best Regards
    Lucien