cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
drrai66 Resolver I
Resolver I

Use Code from Formula Bar of One Conditional Column To create Other Conditional Columns

Hi Experts,

I have 3 fields in my data from which I want to Create 3 conditional Columns. The Conditions are same for all the 3 conditional columns to be created. I have created a Conditional Column as COLUMN1 as per the picture. Is there a way I can use the code in Formula Bar to create 2 more Conditional Columns from other 2 fields. I don't want to type in Conditions for other 2 Columns but want to use Highlighted code.

Thanks

Deepak

 

DeepakConditional.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: Use Code from Formula Bar of One Conditional Column To create Other Conditional Columns

Hi drrai66,

 

Based on your requirement, you want to add multiple columns in one function, right?

 

To achieve your requirement, you can write a custom function like below:

 

Table.AddColumns = (table as table, addedColumns as list) as table =>

        List.Accumulate(

            addedColumns,

            table,

            (t, d) => Table.AddColumn(t, d{0}, d{1}, d{2}?))

 

The result is like below and you can refer to my PBIX file here:

https://www.dropbox.com/s/4b3hk747pju86h9/For%20drrai66.pbix?dl=0

1.PNG 

 

Regards,

Jimmy Tao

View solution in original post

1 REPLY 1
Community Support
Community Support

Re: Use Code from Formula Bar of One Conditional Column To create Other Conditional Columns

Hi drrai66,

 

Based on your requirement, you want to add multiple columns in one function, right?

 

To achieve your requirement, you can write a custom function like below:

 

Table.AddColumns = (table as table, addedColumns as list) as table =>

        List.Accumulate(

            addedColumns,

            table,

            (t, d) => Table.AddColumn(t, d{0}, d{1}, d{2}?))

 

The result is like below and you can refer to my PBIX file here:

https://www.dropbox.com/s/4b3hk747pju86h9/For%20drrai66.pbix?dl=0

1.PNG 

 

Regards,

Jimmy Tao

View solution in original post

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors
Top Kudoed Authors