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

Creating new column using values from column A, conditional on columns B and C

Hi, I'm struggling a lot with this problem, any help would be appreciated

 

I have a table like this:

ABC
2417
1427
6437
2447
1357
4767
6277
34814
63914
351014
741114
351214
751314
351414


I want to create a new column such that:

If B != C for the row, then we want the value from A WHERE the C for the row in question = B from any of the rows.

Else if B == C, we wnat the value from A.

 

The resulting table looks like:

ABCNew column
241762
142762
643762
244762
135762
476762
627762
3481435
6391435
35101435
74111435
35121435
75131435
35141435

 

I have tried:

Weekend inventory = if(
[B]<>[C],SELECTCOLUMNS(filter(Table,[B]=[C]),"temp",[A]),
[A])
 
But this gives me an error which I assume is because there are multiple matching B and C values...
 
Any help would be really appreciated!!!!!!
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

 

Try this formula

New Column = 
VAR a_val = 'Table'[A]
VAR b_val = 'Table'[B]
VAR c_val = 'Table'[C]
RETURN
IF (
    b_val <> c_val,
    LOOKUPVALUE( 'Table'[A], 'Table'[B], c_val),
    a_val)

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi,

 

Try this formula

New Column = 
VAR a_val = 'Table'[A]
VAR b_val = 'Table'[B]
VAR c_val = 'Table'[C]
RETURN
IF (
    b_val <> c_val,
    LOOKUPVALUE( 'Table'[A], 'Table'[B], c_val),
    a_val)
Anonymous
Not applicable

Thanks so much for your reply!!!

 

But I am getting this error for some reason:

"A table of multiple values was supplied where a single value was expected."

Anonymous
Not applicable

Look I think your formula is pretty sound - I'll go check my data to see if there are multiple matches between columns B and columns C.....

 

Thanks for your help!!!

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.