DAX Power BI Measure If Then with Numbers and Text

jamiers

New Member
Joined
May 20, 2007
Messages
15
Good morning all,

The answer to my last post was very helpful -- I'm appreciative of the support I received here. I'm attempting to complete another task.

I am creating a measure and cannot put this in Power Query because it is looking at other tables.

TextField1 !MergedTraining'[GAP-SH-SA-Primary.GAP SH/SA 1st contains text (an expected cell is SA)
NumberField2 !MergedTraining'[GAP √ SA] contains numbers (an expect response cell be 1)
TextField3 !MergedTraining'[OPER Pos] contains text (an expected response is OPER-SH-SA)

Basically (in my head of not-right-thinking), I want to create an If then statement, but I am running into issues where Power BI is throwing an error that says that I can't use text and numbers together.

Let's imagine that they are all in the same table "CHECK" for our purposes here. I will change that later.
If TextField"1"=SA & NumberField2="1" & TextField3="OPER-SH-SA", then output "Yes", If not "No"

  1. I attempted this and it was successful:
    Comply-SSC-SA = IF( FIRSTNONBLANK('!MergedTraining'[GAP-SH-SA-Primary.GAP SH/SA 1st],1)="SA", "YES", "NO")

  2. I attempted to add my next field and failed with the following message: DAX comparison operations do not support comparing values of type True/False with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.
    Comply-SSC-SA = IF( FIRSTNONBLANK('!MergedTraining'[GAP-SH-SA-Primary.GAP SH/SA 1st],1)="SA" & SUM('!MergedTraining'[GAP √ SA]) = 1, "YES", "NO")
I think that if I can figure out TextField1 and NumberField2, I can deal with TextField3 after that (?)...

Any thoughts for this newbie?

Thanks.

Jamie
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
OK I did notice that I failed to double the & in the initial line beginning with FIRSTNONBLANK.... but this is now returning unexpected results. Even when Not true, it is populating with NO. Does anyone know of a better way to write this code?
 
Upvote 0
Could you try something like this?

Measure = IF( FIRSTNONBLANK('!MergedTraining''[GAP-SH-SA-Primary GAP SH/SA 1st'[!MergedTraining'[GAP-SH-SA-Primary.GAP SH/SA 1st], 1) = "SA" && FIRSTNONBLANK('!MergedTraining''[GAP √ SA]'[!MergedTraining'[GAP √ SA]]], 1) = 1 && FIRSTNONBLANK('!MergedTraining''[OPER Pos]'[ !MergedTraining'[OPER Pos]]], 1) = "OPER-SH-SA", "YES", "NO")
 
Upvote 0

Forum statistics

Threads
1,223,702
Messages
6,173,957
Members
452,539
Latest member
delvey

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top