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
shei7141
Helper III
Helper III

maxifs in measure

Hi everyone,

 

I have a table which looks like this:

Project No.PhasesEstCost
1SA10
1

Option

1

15
1

Option

2

11
1

Option

3

15
1PS20
2SA5
2Option16
2Option24
2Option37
2PS1

 

How can I write a measure which can return if the Phases value is not "*option* ", return the estCost as it is, if the Phases value is *option* return the max of estCost of option 1 to option 3 for that particular project. The measure should return something like this:

 

Project No.PhasesEstCostMeasure
1SA1010
1Option11515
1Option211 
1Option315 
1PS2020
2SA55
2Option167
2Option24 
2Option37 
2PS11

Thanks heaps in advance

Cheers,

Shei

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

hi  @shei7141 

You could try this logic:

Measure = 

var _firstoption=CALCULATE(MIN('Table'[Phases]),FILTER(ALLSELECTED('Table'),'Table'[Project No.]=MAX('Table'[Project No.])&&SEARCH("Option",'Table'[Phases],1,0)>0))
var _notoption=CALCULATE(SUM('Table'[EstCost]),FILTER('Table',SEARCH("Option",'Table'[Phases],1,0)=0))
var _option=CALCULATE(MAX('Table'[EstCost]),FILTER(ALLSELECTED('Table'),'Table'[Project No.]=MAX('Table'[Project No.])&&SEARCH("Option",'Table'[Phases],1,0)>0))
return
IF(SEARCH("Option",MAX('Table'[Phases]),1,0)=0,_notoption,IF(MAX('Table'[Phases])=_firstoption,_option))

Result:

1.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

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

View solution in original post

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi  @shei7141 

You could try this logic:

Measure = 

var _firstoption=CALCULATE(MIN('Table'[Phases]),FILTER(ALLSELECTED('Table'),'Table'[Project No.]=MAX('Table'[Project No.])&&SEARCH("Option",'Table'[Phases],1,0)>0))
var _notoption=CALCULATE(SUM('Table'[EstCost]),FILTER('Table',SEARCH("Option",'Table'[Phases],1,0)=0))
var _option=CALCULATE(MAX('Table'[EstCost]),FILTER(ALLSELECTED('Table'),'Table'[Project No.]=MAX('Table'[Project No.])&&SEARCH("Option",'Table'[Phases],1,0)>0))
return
IF(SEARCH("Option",MAX('Table'[Phases]),1,0)=0,_notoption,IF(MAX('Table'[Phases])=_firstoption,_option))

Result:

1.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

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

Measure = 
var p=selectedvalue(ProjectPhases[Project No.])
var ph = SELECTEDVALUE(ProjectPhases[Phases])
var m = CALCULATE(max(ProjectPhases[EstCost]),ALLSELECTED(ProjectPhases),ProjectPhases[Project No.]=p,CONTAINSSTRING(ProjectPhases[Phases],"Option"))
return switch(TRUE(),CONTAINSSTRING(ph,"Option1"),m,CONTAINSSTRING(ph,"Option"),BLANK(),sum(ProjectPhases[EstCost]))

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.