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
rjobaan
Frequent Visitor

Dynamically create column based on measure name

I have two tables:

One table with all measure names in it:

TABLE NAME: MEASURES

Column OBJECT

Column Table

 

other table with the measur calculation in it

TABLE NAME: ACTUAL

Measure Actual - Gross

Measure Actual -Nett

 

Now i wanti to create a column as follows

 

KPI=
SWITCH (
    TRUE(),
  'MEASURES'[OBJECT] ="Actual - Gross",[Actual - Gross],
 'MEASURES'[OBJECT] ="Actual - Nett",[Actual - Nett],
0
)

 

This is working, but I have a lot of measures so this will take me a lot of time to create

The name of the measure is the same as the name in the object

 

Is there a possbility to make the dax code as follows:

 

KPI=
  'MEASURES'[OBJECT_NAME] ,MEASURES'TABLE'.MEASSURES[OBJECT]]
)
hopefully you understand what i try to accomplish

 

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @rjobaan ,

 

According to your statement, I know your requirement is that you want to auto-match the measure name in "Measure" table with the actual measures by code in format ([Actual measure], table name , [MeasureName]).

As far as I know, there is not any function in Power BI that support us to do this. I think SWITCH() function should be the best way. I think you can update your code as below.

KPI =
SWITCH (
    'MEASURES'[OBJECT],
    "Actual - Gross", [Actual - Gross],
    "Actual - Nett", [Actual - Nett],
    "Measure3", [Measure3],
    ...,
    0
)

Add all measures names and all measure into this code.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This is already what I have, but i have to many measures..And if measure are deleted or added I need to add again.

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.