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
MatthewFiero
Helper I
Helper I

Calculate the number of rows using SEARCH and FILTER

Hello Power BI Community,

 

I am relatively new to Power BI. I'm about 3 weeks in now and learning fast. What an amazing tool! 

 

I'm trying to create a measure to count the number of instances with two conditions. One condition is that it containts the word "PENDING" in one column and prior to 2019 for the date.

 

This is what I have:

WIP = CALCULATE(COUNTROWS(FAST),SEARCH("PENDING",FAST[Claim Status],,0), CALCULATE(COUNTROWS(FAST),FAST[Create Date] < DATE(2019,01,01)))
 
Separetely these two filters work but together I am getting the error  that CALCULATE has been used as a TRUE/FALSE statement and I don't understand exactly what that means. 
 
Is anyone able to help me work through this?

Thank you for your time and thank you for this wonderful community! 
 
Matthew
1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@MatthewFiero 

Try it this way:

WIP = 

CALCULATE(
    COUNTROWS(FAST),
    FILTER(
        FAST,
        FAST[Claim Status] = "PENDING" && FAST[Create Date] < DATE(2019,01,01)
    )
)

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

4 REPLIES 4
Fowmy
Super User
Super User

@MatthewFiero 

Try it this way:

WIP = 

CALCULATE(
    COUNTROWS(FAST),
    FILTER(
        FAST,
        FAST[Claim Status] = "PENDING" && FAST[Create Date] < DATE(2019,01,01)
    )
)

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi @Fowmy ,

 

Thank you for such a quick response. What if the claim status only contains the word "PENDING"? In my case there are multiple different pending status. 

 

I had no idea you could use the && function like that which should be very helpful in the future!

 

Thank you,
Matthew

@MatthewFiero 
The DAX that I shared will only take into account if the value is only "Pending".

Hope the solution works for you

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Looks like this may work except I have 1 extra value for some reason (I'll have to check the data)

 

WIP =

CALCULATE(
COUNTROWS(FAST),
FILTER(
FAST,
SEARCH("PENDING",FAST[Claim Status],,0) && FAST[Create Date] < DATE(2019,01,01)
)
)

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.