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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
clarainesgg
Helper I
Helper I

Conditional Column PowerBi Editor

Hi, 

 

I did a conditional column with one field. However, I need to add another clause AND in the second clause.

 

if "Name"="gonzalez" then 15754

else if name="perez "and license_1=556 then 885

else Medical_lincense

 

clarainesgg_0-1732116856515.png

 

Thanks!

 

Clara 

 

3 ACCEPTED SOLUTIONS
Jai-Rathinavel
Super User
Super User

Hi @clarainesgg Click on Custom Column and enter the below m code

 

JaiRathinavel_0-1732118080324.png

M Code:

if [name] = "gonzalez" then 15754
else if [name] = "perez" & [license_1] = 556 then 885
else [Medical_license_1]

 M Code snapshot:

 

JaiRathinavel_2-1732118284064.png

 

Did I answer your question? If yes, please mark my post as a solution.

 

Thanks,

Jai




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

Bibiano_Geraldo
Super User
Super User

Hi @clarainesgg

In power query, on your last step, right and insert step after and in formula bar paste this code:

= Table.AddColumn(PreviousStepName, "Custom Column", each 
    if [Name] = "gonzalez" then 15754
    else if [Name] = "perez" and [license_1] = 556 then 885
    else [Medical_lincense]
)

 

Replace PreviousStepName with the name of your previous step. If the step name contains spaces or special characters, enclose it in # and double quotes (#"Step Name").

 

Additionally, ensure you replace the column names (Name, license_1, and Medical_lincense) with the actual column names from your tabl e.

 

View solution in original post

Anonymous
Not applicable

Hi @clarainesgg 

You can also choose to use Dax to meet your needs.

license = IF([Name]="gonzalez",  15754,IF( [Name] ="perez" && [license_1] =556 , 885 ,[Medical_lincense]))

 

vjialongymsft_0-1732171035641.png

 

 

 

 

 

 

 

Best Regards,

Jayleny

 

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

Hi @clarainesgg 

You can also choose to use Dax to meet your needs.

license = IF([Name]="gonzalez",  15754,IF( [Name] ="perez" && [license_1] =556 , 885 ,[Medical_lincense]))

 

vjialongymsft_0-1732171035641.png

 

 

 

 

 

 

 

Best Regards,

Jayleny

 

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

Bibiano_Geraldo
Super User
Super User

Hi @clarainesgg

In power query, on your last step, right and insert step after and in formula bar paste this code:

= Table.AddColumn(PreviousStepName, "Custom Column", each 
    if [Name] = "gonzalez" then 15754
    else if [Name] = "perez" and [license_1] = 556 then 885
    else [Medical_lincense]
)

 

Replace PreviousStepName with the name of your previous step. If the step name contains spaces or special characters, enclose it in # and double quotes (#"Step Name").

 

Additionally, ensure you replace the column names (Name, license_1, and Medical_lincense) with the actual column names from your tabl e.

 

Jai-Rathinavel
Super User
Super User

Hi @clarainesgg Click on Custom Column and enter the below m code

 

JaiRathinavel_0-1732118080324.png

M Code:

if [name] = "gonzalez" then 15754
else if [name] = "perez" & [license_1] = 556 then 885
else [Medical_license_1]

 M Code snapshot:

 

JaiRathinavel_2-1732118284064.png

 

Did I answer your question? If yes, please mark my post as a solution.

 

Thanks,

Jai




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.