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

IF(CountIFS Greater than + other criteria

Please see below my excel formula which is returning the right result 

Excel Formula =IF(COUNTIFS(A:A,A2,B:B,"cs-ac",C:C,"Passed")>0,"Passed","No")

 

I have tried the dax formulas below but not returning what I expect, any help to perfect Dax would be great .

 

Status = IF(COUNT(Data[value])>0,IF(AND(Data[type]="cs-ac",Data[state]="Passed"),"Passed","No"))
 
Status = Var P = COUNT(Data[value])
Return
SWITCH(
TRUE(),
P >0,IF(AND([sic_type]="cs-ac",[state]="Passed"),"Passed","No"))
 
Sample data and output

A               B                   C                          D

valueTypeStateOutput
01ed570eundercompleteNo
01ed570eprogrcompleteNo
01ed570eundercompleteNo
01ed570edata-completeNo
01ed570ean-incompleteNo
01ed570eregiscompleteNo
01ed570enetwocompleteNo
01ed570ecs-accompleteNo
01ed570ealgorcompleteNo
01ed570ecs-accompleteNo
01ed570ereprein_progressNo
0423565bprogrcompletePassed 
0423565bundercompletePassed 
0423565bregiscompletePassed 
0423565bnetwocompletePassed 
0423565bcs-accompletePassed 
0423565bpythocompletePassed 
0423565balgorcompletePassed 
0423565bcs-accompletePassed 
0423565bprogrenrolledPassed 
0423565bnetwoenrolledPassed 
0423565bprogrenrolledPassed 
0423565brepreenrolledPassed 
0423565bteachenrolledPassed 
0423565bhow-cenrolledPassed 
0423565bintroenrolledPassed 
0423565bintroenrolledPassed 
0423565bdesigenrolledPassed 
0423565bobjecenrolledPassed 
0423565bunderenrolledPassed 
0423565bdata-droppedPassed 
0423565bprogrin_progressPassed 
0423565bintroin_progressPassed 
0423565bncce-droppedPassed 
0423565bgcse-droppedPassed 
0423565bimpacin_progressPassed 
0423565bcs-acpassedPassed 

 

@Greg_Deckler @Ashish_Mathur 

PM

 

1 ACCEPTED SOLUTION

I have managed to fix the problem by creating a calculated Table, please formula below :

 

Status= SUMMARIZE('Table',[value],"Achievement",IF(CALCULATE(COUNT('Table',[value]),'Table',[Type]= "cs-ac",'Table',[state]="pass")>=1,"Passed","No"))

View solution in original post

11 REPLIES 11
nandukrishnavs
Super User
Super User

@moeconsult 

 

I couldn't understand the logic for the expected output. Could you explain it?

 

Please refer to the below logic for the calculated column.

 

Status = 
var _Count=COUNTX (FILTER ( 'Table', EARLIER ( 'Table'[value] ) = 'Table'[value]  ),'Table'[value] )
var _type= IF('Table'[Type]="cs-ac",TRUE(),FALSE())
var _state= IF('Table'[state]="Passed",TRUE(),FALSE())
var _status= IF(_Count>0,IF(AND(_type,_state),"Passed","No"),"Passed")
return _status

 

Maybe you have to tweak the logic of the _status variable.



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 


Regards,
Nandu Krishna

 

It working perfectly okay for No but not its returning Pass and No for when I expect only Pass

@moeconsult 

I don't know who you're answering to. If you are referring to my solution, it yields exactly the output that you show in your table

Please mark the question solved when done and consider giving kudos if posts are helpful.

 Cheers 

SU18_powerbi_badge

I am replying to both solutions thanks

Hi @moeconsult ,

 I try the formula that @AlB suggested and it works fine in my sample.  So I'm confused what you encountered. Can you please share a few screenshots of what you tried?  More details will help us understand more clearly.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Status =
var _Count=COUNTX (FILTER ( 'Data', EARLIER ('Data'[Value]) = Data[Value]),Data[Value])

var _type= IF(Data[type]="cs-ac",TRUE(),FALSE())

var _state= IF(Data[state]="Passed",TRUE(),FALSE())

var _status= IF(_Count>0,IF(AND(_type,_state),"Passed","No"),"Passed")
return _status

 

That is the formula that I tried 

sta.JPG

Please see screenshot above is meant to be Pass through out but its returning NO . 

Hi @moeconsult ,

 

I reproduced it using your formula. Please try the formula that @AlB suggested. I tried this and it worked fine.

Status = 
IF (
    CALCULATE (
        COUNT ( Data[Value] ),
        Data[Type] = "cs-ac",
        Data[State] = "Passed"
    ) > 0,
    "Passed",
    "No"
)

1.PNG

If this still can't work for you, please share more details.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-xuding-msft @AlB 

 

I am still having same issues, please see screenshot with my actuall data for both "Passed" and "No" 

As before its working well for the No but return No and Pass for when it should be pass alone .

Works FineWorks FineStill returning No when it should all be PassStill returning No when it should all be Pass

 

@v-xuding-msft @AlB  Any suggestion would help.

I have managed to fix the problem by creating a calculated Table, please formula below :

 

Status= SUMMARIZE('Table',[value],"Achievement",IF(CALCULATE(COUNT('Table',[value]),'Table',[Type]= "cs-ac",'Table',[state]="pass")>=1,"Passed","No"))

AlB
Super User
Super User

Hi @moeconsult 

For the value to get an outpu "Passed" there must be at least one row in which  Type is "cs-ac" and State "Passed". Is this correct? If so, you can create a calculated column in your table:

Output =
IF (
    CALCULATE (
        COUNT ( Table1[Value] ),
        Table1[Type] = "cs-ac",
        Table1[State] = "Passed"
    ) > 0,
    "Passed",
    "No"
)

Please mark the question solved when done and consider giving kudos if posts are helpful.

 Cheers 

SU18_powerbi_badge

Thanks for your help, this working but not perfect, its returning No for everything that meant to be no but it is returning Pass and No for all that is meant to be Only Pass

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.