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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
jcastr02
Post Prodigy
Post Prodigy

MCode - if & And Formula

I'm trying to create a custom column, with PowerQuery.  I'm having difficulty with the MCode.  How could this be re-written in PQ?

Temp Closure = if('Emergency Status'[RX]="TRUE" && 'Emergency Status'[FE]="TRUE","FE/Rx",
if('Emergency Status'[RX]="FALSE" && 'Emergency Status'[FE]="TRUE","FE",
if('Emergency Status'[RX]="TRUE" && 'Emergency Status'[FE]="FALSE","RX",
if('Emergency Status'[RX]="FALSE" && 'Emergency Status'[FE]="FALSE","Restricted Hrs."))))

1 ACCEPTED SOLUTION
rubayatyasmin
Community Champion
Community Champion

Hi, @jcastr02 

try using if...then ...else 

e.g, select the emergency status query in power query editor >> add column >> custom column >> 

= if [RX] = true and [FE] = true then "FE/Rx"
else if [RX] = false and [FE] = true then "FE"
else if [RX] = true and [FE] = false then "RX"
else "Restricted Hrs."
)


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


View solution in original post

1 REPLY 1
rubayatyasmin
Community Champion
Community Champion

Hi, @jcastr02 

try using if...then ...else 

e.g, select the emergency status query in power query editor >> add column >> custom column >> 

= if [RX] = true and [FE] = true then "FE/Rx"
else if [RX] = false and [FE] = true then "FE"
else if [RX] = true and [FE] = false then "RX"
else "Restricted Hrs."
)


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.