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
cathoms
Helper V
Helper V

Create custom column based on values in multiple other columns

Hello!

 

I have columns for values that compare how a provider is utilizing office visit codes versus their peer group. I need to flag values at certain thresholds so I created custom columns to flag so-called "opportunities", which I then use for conditional formatting. One of the flags depends on the values in the other columns and I can't get it to work.

 

Here is what the current end product looks like:

cathoms_0-1625667789769.png

 

The problem is that 99215 Diff should flag when below -10 but only if there are no other flags. As you can see, that is not happening. What am I doing wrong?

Here is the M Code:

 

= Table.AddColumn(#"Added 99214 Opportunity", "99215 Opportunity", 
each if [99215 Diff] < -0.1 and [99212 Opportunity] = 1 or [99213 Opportunity] = 1 or [99214 Opportunity] = 1 then "0"
else if [99215 Diff] < -0.1 then "1"
else "0")

 

 

I would appreciate any help!

1 ACCEPTED SOLUTION
cathoms
Helper V
Helper V

I decided it would be easier to just create a new column using DAX, which is probably what I should have done from the start. Anywho, my DAX code for the column looks like this:

99215 Potential = 
IF(
    EstVisits_21Q1[99215 Diff] < -0.1 && NOT(
        EstVisits_21Q1[99212 Opportunity] = 1 || EstVisits_21Q1[99213 Opportunity] = 1 || EstVisits_21Q1[99214 Opportunity] = 1
    ), 1,
    0
)

 

View solution in original post

6 REPLIES 6
cathoms
Helper V
Helper V

I decided it would be easier to just create a new column using DAX, which is probably what I should have done from the start. Anywho, my DAX code for the column looks like this:

99215 Potential = 
IF(
    EstVisits_21Q1[99215 Diff] < -0.1 && NOT(
        EstVisits_21Q1[99212 Opportunity] = 1 || EstVisits_21Q1[99213 Opportunity] = 1 || EstVisits_21Q1[99214 Opportunity] = 1
    ), 1,
    0
)

 

watkinnc
Super User
Super User

Sorry, the second parentheses should go after the [99214 Opportunity] =1) like that. 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Yes, I figured and that is what I tried but it didn't work.

watkinnc
Super User
Super User

Try this:

Just place parentheses before [99212 Opportunity] and then after [99214 Opportunity] so that all of the "or"s after the "and" are a single parenthesized statement.

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

I tried the parentheses but that didn't work.

cathoms
Helper V
Helper V

Note that I did try changing the order and putting the "else if" statement first to no avail. I also tried adding parentheses around the set of "or" statements to no effect.

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.