cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Thackeb
Helper I
Helper I

IF with AND

Asking for assistance with a Dax using If(And) or Switch. Please note that my tables are read only and I'm limited with using regular Dax. 

 

Please assist if possible. Please note that my data tables are "read only" and I'm limited with what I can utilize. I cannot add calculated columns. In my Oracle/Hyperion query I have the following:

 

IF(Category_2 == "CUT SHEET PAPER" && PFX_NUM == "UNV" || PFX_NUM="OFF" || PFX_NUM== "IVR"|| PFX_NUM=="UFS") ("Excluded from Program") else ("Meets Criteria")

 

My thoughts are the below, however I can only add values, when trying to reference [Category 2] or [PFX_NUM]

IF(AND ([Category_2] = "CUT SHEET PAPER", [PFX_NUM] IN ("UNV","OFF","IVR","UFS"),

("Excluded from Program","Meet's Criteria")))

 

Is there a prior word such as ALL that I could add before [Category 2] or [PFX_NUM]?

 

My other thoughts were to CALCULATE Sales based on the conditions. 

 

All help is greatly appreciated! Happy Holidays!

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Thackeb ,

 

You could create a measure:

measure = 
IF(Category_2 in {"CUT SHEET PAPER", other values} && PFX_NUM in {"UNV", "OFF", "IVR", "UFS"}, "Excluded from Program", "Meets Criteria")

You could also create slicers and use ALLSELECTED() or VALUES() function to get the dynamic value:

measure = 
IF(Category_2 in VALUES([column1]) && PFX_NUM in VALUES([column2]), "Excluded from Program", "Meets Criteria")

If you want to calculate Sales based on the above conditions, you could refer:

measure = 
CALCULATE(sum(sales),Filter(ALLSELECTED('table'),Category_2 in {"CUT SHEET PAPER", other values} && PFX_NUM in {"UNV", "OFF", "IVR", "UFS"}))

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

Hi @Thackeb ,

 

You could create a measure:

measure = 
IF(Category_2 in {"CUT SHEET PAPER", other values} && PFX_NUM in {"UNV", "OFF", "IVR", "UFS"}, "Excluded from Program", "Meets Criteria")

You could also create slicers and use ALLSELECTED() or VALUES() function to get the dynamic value:

measure = 
IF(Category_2 in VALUES([column1]) && PFX_NUM in VALUES([column2]), "Excluded from Program", "Meets Criteria")

If you want to calculate Sales based on the above conditions, you could refer:

measure = 
CALCULATE(sum(sales),Filter(ALLSELECTED('table'),Category_2 in {"CUT SHEET PAPER", other values} && PFX_NUM in {"UNV", "OFF", "IVR", "UFS"}))

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
rsbin
Super User
Super User

@Thackeb,

I believe the "IN" function requires curly braces and you may have some parenthesis that are out of place.  Try:

 

IF(AND ([Category_2] = "CUT SHEET PAPER", [PFX_NUM] IN {"UNV","OFF","IVR","UFS"}),

"Excluded from Program","Meets Criteria")

I'm not an expert at writing syntax on the fly, so above may need a tweak or two.

 

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors