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

Calculate Count formula

Hello

 

Power BI novice user here. I'm trying to use the calculate(count...) formula to work out the total number of results that are >=5 and <=7 (i.e. all 5's, 6's, 7's). The dataset has '99' as a response (essentially 'Not sure' if converted as 'string') and I want to exclude these as part of the calculation.

 

Hoping someone can assist.

 

Thanks

1 ACCEPTED SOLUTION

CALCULATE(COUNT('Report1'[Educate employees]),'Report1'[Educate employees]>=5 && 'Report1'[Educate employees]<=7)

 

the && functions as an AND when turning to SQL, which means the filter has to pass BOTH criteria

View solution in original post

11 REPLIES 11
decarsul
Helper IV
Helper IV

Not entirely sure what you mean, but since i'm searching for help myself, i figured maybe i can assist in this.

 

Have you tried something like:

 

Calculate(count(ID);[result] >= 5 && result <=7)?

I don't think I understand your response, but I'm unable to make that work...

Can you give me / us a rough sketch of how your table looks?

Can be fictious data.

Educate employees
4
99
7
5
7
7
7
6
7

this is the formula im using, but doing it this way also includes the '99' which i don't want...

 

Count of 5-7 Educate Employees =
CALCULATE(COUNT('Report1'[Educate employees]),'Report1'[Educate employees]>=5)
 
After this formula I'm running a 'Divide' formula to convert the figures into percent. That part of the formula works fine. I've validated my result from the 'calculate' formula within excel so I know what result I should receive...

CALCULATE(COUNT('Report1'[Educate employees]),'Report1'[Educate employees]>=5 && 'Report1'[Educate employees]<=7)

 

the && functions as an AND when turning to SQL, which means the filter has to pass BOTH criteria

Can create a seperate column and do a sum on that.

=IF(AND('Report1'[Educate employees] >= 5;'Report1'[Educate employees] <= 7);1;0)

 

This will return a value of 1 when its between 5 and 7, and value of 0 when its not, and will do this on each row.

Then you can just SUM() the new column

That works, but for some reason, the result that's coming through isn't correct, so it's like a source data issue. I will keep investigating. Thanks

I think i know why it's not giving me the answer it should be....i think the divide formula is also including the '99s' as part of the total, which I want to exclude from the overall calculation

 

Percent 5-7 Educate Employees =
DIVIDE([Count of 5-7 Educate Employees],COUNT('Report 1'[Educate employees])
 
is what I have currently...
 

Hi @aaronvincentnz ,

Is there anything else we can help with regarding this thread?

Best Regards

Rena

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

Nah I think it's all sorted. Thanks

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.