Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
powerbi_user1
Frequent Visitor

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 5
v-yuezhe-msft
Employee
Employee

@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

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

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

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

@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. 

Columns cannot be dynamic based upon user selection. Just use the disconnected table trick to use your measure as a slicer.

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

What is "the disconnected table trick"?

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.