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
Anonymous
Not applicable

Change column based on measure value

Hi everyone,

 

I know you have an idea what can be the problem, and how to solve it.

The situation is the following:

I have created a measure based on filter value. DAX:

 

 

 

Measure = IF(FILTERS('TABLE_1'[column_1]) = "1", TRUE(), FALSE())

 

 

 

This measure works. If I change the filter, the value updates correctly.

 

I have a table (TABLE_2) that contains two column, lets call it "A" and "B". I want to create a new column ("C"). This column should be the same with "A" or "B" columns, based on my measure. DAX:

 

 

CreatedCol = IF([Measure] = TRUE(), TABLE_2[A], TABLE_2[B])

 

 

And it comes with a following error: "A table of multiple values was supplied where a single value was expected."

If I update the DAX of the new column to 

 

 

CreatedCol = IF(TRUE() = TRUE(), TABLE_2[A], TABLE_2[B])

 

 

or

 

 

CreatedCol = IF(FALSE() = TRUE(), TABLE_2[A], TABLE_2[B])

 

 

, it works.

 

So both the measure and the column work separately, but when I combine them, it breaks.

I hope you can save me.

Thanks in advance!

1 ACCEPTED SOLUTION

Hi @Anonymous ,

You cannot create column "C" based on your measure's value. 

Calculated columns are only calculated when you first define them and during a dataset refresh, it will not change by filters, it is a definite value, if you expect the value changes with filter, you can only use a measure.

 

In a measure, columns cannot be referenced directly, MAX function in a measure can return the current value in the same row of the column.

 

You can learn more about measures and calculated column in this article: calculated-measures-vs-calculated-columns

 

Best Regards,
Community Support Team _ kalyj

 

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , In DAX measure you need to have aggregation

CreatedCol = IF([Measure] = TRUE(), Max(TABLE_2[A]), max(TABLE_2[B]))

or

CreatedCol = IF([Measure] = TRUE(), sum(TABLE_2[A]), sum(TABLE_2[B]))

 

 

Also , you can not use measure in a column

Anonymous
Not applicable

Dear @amitchandak,

thank you for your answer!

So as I understand if "TABLE_2[A]" and "TABLE_2[B]" are string columns, it is not possible to create column "C" based on my measure's value?

Hi @Anonymous ,

You cannot create column "C" based on your measure's value. 

Calculated columns are only calculated when you first define them and during a dataset refresh, it will not change by filters, it is a definite value, if you expect the value changes with filter, you can only use a measure.

 

In a measure, columns cannot be referenced directly, MAX function in a measure can return the current value in the same row of the column.

 

You can learn more about measures and calculated column in this article: calculated-measures-vs-calculated-columns

 

Best Regards,
Community Support Team _ kalyj

 

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

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.