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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Anonymous
Not applicable

Countifs with multiple conditions in PowerQuery in PB

Hello Wonderful people

 

An example of the countifs formula with multiple conditions I am currently using in Excel is given below.  I wish to replicate the same formula in PowerQuery in PB:

=COUNTIFS(Append1!$BF:$BF,">=01/01/2020",Append1!$BF:$BF,"<18/11/2022",Append1!$D:$D,"<>24 Application withdrawn")

At the moment, I am using the filter option to filter out the 24 Application withdrawn condition but it's better to use a SQL to do the job!

I know it's NOT going to be easy in PB.

Thank you in advance.


1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

This is my test data.  

MicrosoftTeams-image (6).png

MicrosoftTeams-image (9).png

MicrosoftTeams-image (10).pngMicrosoftTeams-image (7).png

MicrosoftTeams-image (8).png

 

Best Regards,

Neeko Tang

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

5 REPLIES 5
Anonymous
Not applicable

@neekotang, thank you.  This works in SSMS.  

Anonymous
Not applicable

@neeko tang, does your syntax work in PowerBI or SSMS?

Anonymous
Not applicable

Hi @Anonymous ,

 

This is my test data.  

MicrosoftTeams-image (6).png

MicrosoftTeams-image (9).png

MicrosoftTeams-image (10).pngMicrosoftTeams-image (7).png

MicrosoftTeams-image (8).png

 

Best Regards,

Neeko Tang

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

 

 

Anonymous
Not applicable

Hi @Anonymous ,

 

You can use the following SQL statements.

 

select count(*)
from table
where date >= '2020-01-01' and date <= '2022-11-18' and column <> '24 Application withdrawn'

 

You also can refer to the following posts that may be helpful to you:

SQL Countif function - Stack Overflow

sql - How to do countIf() in Oracle - Stack Overflow

COUNTIF in SQL: COUNT(CASE WHEN … THEN 1 END) (modern-sql.com)

 

Best Regards,

Neeko Tang

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

Bifinity_75
Solution Sage
Solution Sage

Hi @Anonymous , If I have understood you correctly, and assuming that your data model is something similar to this:

Bifinity_75_0-1668790606737.png

 

- Create a custom column, and insert this formule:

if [Date]>= Date.FromText("2020-01-01") and
[Date]<= Date.FromText("2022-11-18") and
[Column]<>"<> 24 Application withdrawn" 
then 1 else 0

 

- The result:

Bifinity_75_1-1668790719325.png

 

Best regards

 

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

Check out the May 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

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