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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Create Table with condition on columns (to add)

Hello,


here's my situation : depending on user selection on a segment, I want to create a table that selects either the column1, either column2

Table = 
var user_choice = [sel] --= selectedvalue of a segment menu
return

if (user_choice="a",

SELECTCOLUMNS(
      
    data,"id",data[id],"DATA_LIB", data[COLONNE1],"VALUE",data[VALEUR])
    
,--else if = b 

SELECTCOLUMNS(  
    data,"id",data[id],"DATA_LIB", data[COLONNE2],"VALUE",data[VALEUR])
)

 

It's not working. Is it normal ?

Aim : I'd like to change my column reference in my bar charts depending the situation

 

(Today I duplicate the vizualiation and change the field)


Thanks ! 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

looks ok.  You might be interested in this video

 

https://www.youtube.com/watch?v=lFd2hjkKz_Q

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

looks ok.  You might be interested in this video

 

https://www.youtube.com/watch?v=lFd2hjkKz_Q

Anonymous
Not applicable

Great ! Thanks !

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors