cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hede92
Helper II
Helper II

Create new column with specific data from a different column

Hi everyone

 

I have a a table where i need a new column made based on info on one of the other columns.

 

The table looks like this 

Order No.TypeDescription
1A(blank)
1B(blank)
1CNext week delivery
2A(blank)
2BCheck bounced
2C

Return to sender

 

I want to create a new column that duplicates the Description of a Order No. where the Type is C to the rest of the rows of that Order. So in the end it should look like this:

Order No.TypeDescriptionNew column
1A(blank)Next week delivery
1B(blank)Next week delivery
1CNext week deliveryNext week delivery
2A(blank)Return to sender
2BCheck bouncedReturn to sender
2CReturn to senderReturn to sender

 

I achieved this already with a simple LOOKUPVALUE measure:

 

LOOKUPVALUE(Table[Description], Table[Type], "C", Table[Order No.], SELECTEDVALUE(Table[Order No.]))

 

But the calculation is too heavy for the amount of rows i have. That's why i want it done as a calculated column so the heavy lifting is done when the user opens the report.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Hede92 , Try new column

New column =
var _ord = [Order No]
var _type = "C"
return
if(isblank([Description]), maxx(filter(Table, [Order No] =_ord && [Type] ="C"),[Description]) ,[Description])

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Hede92 , Try new column

New column =
var _ord = [Order No]
var _type = "C"
return
if(isblank([Description]), maxx(filter(Table, [Order No] =_ord && [Type] ="C"),[Description]) ,[Description])

Thank you for the swift answer @amitchandak 

 

There was a little misunderstanding in how i wanted the column. Your calculation first checked for a description and then found the one with type "C" if the current Description was blank. I needed all to be from their respective type "C", so i altered your calculation and removed the IF sentence along with isblank.

Like this:

New column =
var _ord = [Order No]
var _type = "C"
return
maxx(filter(Table, [Order No] = _ord && [Type] = _type),[Description])

That did the trick and now it works like a charm. Thank you for the help.

 

Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors