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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
apolotakeshi
Frequent Visitor

Using switch to dinamically create a dimension (need list not values)

Hi all I have a Table4 in which I select the value that I want, it is either 1 or 2.

if it is 1, i want the column to show the values that exists in Table_01 column Dbase17, else I want them to return the Table_02 data.

 

how can i do it?


here is what I have so far:

Dinamic_Column =
if(
SELECTEDVALUE(Table4[Value])="1"
;RELATED(Table_01[Dbase17])
;RELATED(Table_02[Dbase16])
)

also tried:
SWITCH(FIRSTNONBLANK('Table4'[Value];1)
;"1"; RELATED(Table_01[Dbase17])
;"2"; RELATED(Table_02[Dbase16])
;"xx")

None of them worked.
PS: the tables are connected, I have a field that connects Dbase17 with my Dbase and Dbase to Dbase16

6 REPLIES 6
v-huizhn-msft
Employee
Employee

Hi @apolotakeshi,

Please create a calculated column using the formula below in Table4.

Dinamic_Column =
if(Table4[Value]="1"
;RELATED(Table_01[Dbase17])
;RELATED(Table_02[Dbase16])
)


We assume the column including either1 or 2 named as "column1". Then create a table visual, select the Table4[column1] and Dinamic_Column as value level. Create a slicer including Table4[column1], the visual will change as you select different value in slicer.

Best Regards,
Angelia

Related works if there is one to many relationship. From table 4 to table1 , you have many to one.

create the above calculated column on table 1 instead.

 

Dynamic_Column =
if(Trelaed(table4[Value])="1"
;Dbase17
;Dbase16)
)

Hi @v-huizhn-msft!! I got the following error:

"The column 'Table_01[Dbase16]' either doesn't exist or doesn't have a relationship to any table available in the current contex."

here is a sample of the tables, I will only try to use Table_01 for now, but is the same structure for table_02

the possible values for field Value in table4 are 1,2.

Dinamic_column is the one i'm trying to archieve.

test.png

 

 

 

Hi @apolotakesh,

From the screenshot, there is relationship between Table_01 and Table4, what's the field used to relate the two tables? Do you mind share your .pbix file? You can share it by private message.

Best Regards,
Angelia

the column is the D_O which has the values 1,2

that links with Table4.Value which also has 1,2

 

the thing is it only thinks as excel, and I needed it to be a little smarter ;/

like using a field to calculate a new column, or using things like SET analysis from Qlikview.

If i wanted to sort some information by 2 columns I can't get it done...

I think that programming in this language or the DAX Language is not one of the best in order to get things done ;/

Hi @apolotakeshi

I'm not specific about Qlikview, so I can't reproduce your requirement without sample table. I really hope you share it, and list expected result, so that we can post detailed workaround.

Best Regards,
Angelia

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.