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
kouter
Advocate I
Advocate I

Use output of measure to reference column name

Hi,

 

I have a measure that outputs a string. The string will be equal to a column name. I want to be able to use that measure output to reference a column i.e. table1[measureOutput] (where measureOutput is the name of my measure). 

 

I have tried using calculated columns (mycolumn = [measureOutput]), but if I drag this column into table I don't see any values.

 

What is the best way to use measure output to reference a column?

 

Thank you for your help.

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @kouter 
Please refer to attached sample file with the solution

1.png

FilterMeasure = 
VAR TextMeasure = "BMI" -- in your case you need use [Text Measure]
RETURN
    COUNTROWS ( 
        FILTER ( 
            'Table',
            'Table'[ Attribute] = TextMeasure
        )
    )

View solution in original post

6 REPLIES 6
kouter
Advocate I
Advocate I

@tamerj1 

Thank you very much for you help.

tamerj1
Super User
Super User

Hi @kouter 
Please refer to attached sample file with the solution

1.png

FilterMeasure = 
VAR TextMeasure = "BMI" -- in your case you need use [Text Measure]
RETURN
    COUNTROWS ( 
        FILTER ( 
            'Table',
            'Table'[ Attribute] = TextMeasure
        )
    )
kouter
Advocate I
Advocate I

Hi @tamerj1 

 

Thank you very much for your prompt reply.

 

I unpivoted the columns to have their names as attributes. Created the following calculated column

 

my_calc_column = IF(table[attribute] = [measureOutput], table[attribute], BLANK()]

 

however, when I drag this calculated column onto table I don't see any values. Your thoughs on where I'm going wrong? Any suggestions is much appreciated. 

@kouter 
Now comes the next step. Please provide some sample data along with example of the expected result to assist you further.

@tamerj1 

 

 Attribute Value
 length 1.78
 weight 89
 weight 78
length 1.90
BMI27
BMI29
length1.9

 

 

For this example, lets say my measure output will be BMI, then I would like use that measure output to filter the Attribute column resulting in 

 

AttributeValue
BMI27
BMI

29

 

I hope this will suffice, bit hesitant on uploading actual data.

tamerj1
Super User
Super User

Hi @kouter 

not possible. You need to restructure your data, perhaps unpivot the said columns so you can use their names as attributes in a column. 

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.

Top Solution Authors