Forum Discussion

powerbi_user1's avatar
powerbi_user1
Frequent Visitor
8 years ago

Create a dynamic column based on slicer selection

I have two tables:

 

Table 1

ColumnAColumnB
A1B1
A2B2
A3B3

 

Table 2

Column Types
ColumnA
ColumnB

 

I have a slicer for Columns Types and based on selection from that filter a ColumnC should be created in the table - Table1.

Eg., If i select ColumnA in the filter, my Table1 should look like this:

New Table1

ColumnAColumnBColumnC
A1B1A1
A2B2A2
A3B3A3

 

If i select ColumnB in the filter, my Table1 should look like this:

New Table1

ColumnAColumnBColumnC
A1B1B1
A2B2B2
A3B3B3

 

The final goal is to create a slicer with ColumnC as well and it will show values based on selected value in Column Types slicer.

5 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion
    ColumnC Measure = 
    SWITCH(
         MAX('Table 2'[Column Types])),
         "ColumnA",MAX('Table 1'[ColumnA]),
         "ColumnB",MAX('Table 1'[ColumnB]),
         BLANK()
    )
    • powerbi_user1's avatar
      powerbi_user1
      Frequent Visitor

      Greg_Deckler

      Thanks for your reply Greg. But I want to use ColumnC as a slicer anda measure cant be used as a slicer.

      Also, using column C as an independent column shows only the maximum value for the column selected in the slicer. 

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion
        Columns cannot be dynamic based upon user selection. Just use the disconnected table trick to use your measure as a slicer.
  • Anonymous's avatar
    Anonymous
    Not applicable

    powerbi_user1,


    A bit change to Greg_Deckler's DAX.

    ColumnC Measure = 
    SWITCH(
         MAX('Table 2'[Column Types]),
         "ColumnA",MAX('Table 1'[ColumnA]),
         "ColumnB",MAX('Table 1'[ColumnB]),
         BLANK()
    )



    Regards,
    Lydia