Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
turp111
Frequent Visitor

Adding Custom Column and pulling values from other rows

I need to add a new column with conditions but also to pull a value from another row if a certain condition is met.  Below is my table and columns, here are my conditions:

  • If FEE_TYPE = 2 and SF_FIN_SERV_ID <> null then SF_NAME1
  • If FEE_TYPE = 2 and SF_FIN_SERV_ID is null then "NATIONWIDE"
  • If FEE)_TYPE = 1 then SF_NAME1 where SF_FIN_SERV_ID = "TP"

The first two are fairly easy for me, it's the last one that's giving me trouble.  Basically, whenever the FEE_TYPE = 1, that value also needs to be THE PENSION DESIGN GROUP.  I just can't seem to figure out the right syntax for this.  I also added an example of what this should look like.

 

turp111_1-1684785280665.png

turp111_2-1684786010834.png

 

 

1 ACCEPTED SOLUTION

Hi @turp111 

 

Please use this new code:

if [FEE_TYPE] = 2 and [SF_FIN_SERV_ID] <> "" then [SF_NAME1] else if [FEE_TYPE] = 2 and [SF_FIN_SERV_ID] = "" then "NATIONWIDE" else if [FEE_TYPE] = 1 then let vPlan = [PLAN] in List.Max(Table.SelectRows(#"previous step", each [PLAN] = vPlan and [SF_FIN_SERV_ID] = "TP")[SF_NAME1]) else ""

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

4 REPLIES 4
turp111
Frequent Visitor

Thank you, this is helpful.  That said, I should have been more clear about the data.  The example I gave here is just a subset.  The SF_NAME1 column has thousands of rows.  There should have been another column named 'PLAN' in my example.  So this subset of data would be for Plan 10.  I've added a new example of what I'm expecting.  So based on your first solution I'm getting the max value in SF_NAME1 for every row that meets that condition when I really need it only for Plan 10, and then a different value for Plan 20, etc.  Sorry for the initial confusion and hopefully this helps.

turp111_0-1684944892600.png

 

This is just what I was looking for.  Thank you!

Hi @turp111 

 

Please use this new code:

if [FEE_TYPE] = 2 and [SF_FIN_SERV_ID] <> "" then [SF_NAME1] else if [FEE_TYPE] = 2 and [SF_FIN_SERV_ID] = "" then "NATIONWIDE" else if [FEE_TYPE] = 1 then let vPlan = [PLAN] in List.Max(Table.SelectRows(#"previous step", each [PLAN] = vPlan and [SF_FIN_SERV_ID] = "TP")[SF_NAME1]) else ""

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

v-jingzhang
Community Support
Community Support

Hi @turp111 

 

You can add a custom column with below code. Modify "Previous Step Name" accordingly. 

if [FEE_TYPE] = 2 and [SF_FIN_SERV_ID] <> "" then [SF_NAME1] else if [FEE_TYPE] = 2 and [SF_FIN_SERV_ID] = "" then "NATIONWIDE" else if [FEE_TYPE] = 1 then List.Max(Table.SelectRows(#"Previous Step Name", each [SF_FIN_SERV_ID] = "TP")[SF_NAME1]) else ""

vjingzhang_0-1684906719901.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.