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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Clint
Helper V
Helper V

How to use multiple criteria in a filter?

Hello All,

 

I need to calculate a variance between two fields that returns a number I can use for conditional formatting. 

 

The scenario is, I have projects that are of different types; new install, upgrades, module etc.....  Each one of these has a different metric for having the PM assigned (which is a date field in our projects table). 

New installs are Project Start+84 days

Upgrades are Project Start+56 days

Modules are Project Start +42 days.

 

I hae the following DAX that calculates the variance but I don't know how to write so I can factor in the appropriate criteria based on the Project Type?

 

PM Assigned Variance =

CALCULATE(
IF(ISBLANK(
MAXX('Projects',[PMAssigned])),"Not Assigned",
IF(DATEDIFF(
MAXX('Projects',[Project Start Date]),MAXX('Projects',[PMAssigned]),DAY)<=84,0,
IF(DATEDIFF(
MAXX('Projects',[Project Start Date]),MAXX('Projects',[CustomerReview]),DAY)<=91,1,
IF(DATEDIFF(
MAXX('Projects',[Project Start Date]),MAXX('Projects',[CustomerReview]),DAY)>=92,2,0)
)
)
)
)

I know this can be done in separate measures but I'd like to keep this only one column for PM Assigned in the table while also keeping different project types in the same table.

 

2 REPLIES 2
amitchandak
Super User
Super User

@Clint , Not very clear. Try like

Switch( True(),
MAXX('Projects',[PMAssigned]),"Not Assigned",
DATEDIFF(MAXX('Projects',[Project Start Date]),MAXX('Projects',[CustomerReview]),DAY)>=92,2,
DATEDIFF(MAXX('Projects',[Project Start Date]),MAXX('Projects',[CustomerReview]),DAY)<=91,1,
DATEDIFF(MAXX('Projects',[Project Start Date]),MAXX('Projects',[PMAssigned]),DAY)<=84,0,
0)

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Hi Amit,

 

What I need the measure or calc column to do is evaluate the type of project as each Project type has different criteria.  I tried using this measure - and while syntactically valid, returns the wrong results.  PM Variance is a measure that returns a whole number (the difference between PM Start and PM Assigned)

 

PM Assigned Var #2 =
SWITCH(('Projects'[TypeofProject] IN {"Upgrade"}),
[PM Assigned Variance in Days]<=36,0,
[PM Assigned Variance in Days]<=51,1,
[PM Assigned Variance in Days]>=64,2,

SWITCH(('Projects'[TypeofProject] IN {"New Install"}),
[PM Assigned Variance in Days]<=84,0,
[PM Assigned Variance in Days]<=91,1,
[PM Assigned Variance in Days]>=92,2,

SWITCH(('Projects'[TypeofProject] IN {"Module"}),
[PM Assigned Variance in Days]<=39,99,
[PM Assigned Variance in Days]<=49,1,
[PM Assigned Variance in Days]>=50,2,99
)
))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.