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

How to combine count and sum to get a monthly count

I'm looking for a DAX formula (or another method) that will give me a count of employees, per month, hitting their hours target.

Below is an example of the source data (I have a lot more names/months etc.).

On the left is the data, and on the right is the desired output.

2022-05-11 14_45_04-Book1 - Excel.png

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi

 

Try this measure

vb Empl sup a 7h =
VAR _step1 =
FILTER (
ADDCOLUMNS (
SUMMARIZE (
Feuil3,
Feuil3[ID]
),
"Hours",
CALCULATE (
SUM ( Feuil3[Hours] )
)
),
[Hours] >= 7
)
VAR step2 =
COUNTROWS ( _step1 )
RETURN
step2

View solution in original post

Anonymous
Not applicable

Hi Dan,


The difference between our models is that i have only 1 date column and you have 2.

Do you have a date table with a relation ship on one date column ?

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi Dan,


The difference between our models is that i have only 1 date column and you have 2.

Do you have a date table with a relation ship on one date column ?

James, 

I fixed my date relationships and the formula worked perfectly!

Thanks so much!

Anonymous
Not applicable

No probs !! Enjoy Now

Hi James,

See below my date table:

2022-05-12 10_08_22-Utilisation Report V2 - Power BI Desktop.png

The relationship is as below:
2022-05-12 10_09_48-Utilisation Report V2 - Power BI Desktop.png
The shift export only has 1 relationship with the date table.

Thanks again for the speedy response!

Anonymous
Not applicable

Sorry this is my source an excel file imported in Power BI. That is the Feuil3 in my measure.

JamesFr06_0-1652282026227.png

I also work with a dtae table. 

This is the result in BI

JamesFr06_1-1652282135023.png

 

Anonymous
Not applicable

Hi

 

Try this measure

vb Empl sup a 7h =
VAR _step1 =
FILTER (
ADDCOLUMNS (
SUMMARIZE (
Feuil3,
Feuil3[ID]
),
"Hours",
CALCULATE (
SUM ( Feuil3[Hours] )
)
),
[Hours] >= 7
)
VAR step2 =
COUNTROWS ( _step1 )
RETURN
step2

@Anonymous  thank you for your response, I've included that in my actual data, I think it's almost there - but it isn't kicking out the correct figures.

For example - I know that Dec 21 there were around 190 employees working over 60 hours, but the formula is kicking out a much lower figure(53)  See results below:

2022-05-12 08_51_02-Utilisation Report V2 - Power BI Desktop.png2022-05-12 08_55_26-Utilisation Report V2 - Power BI Desktop.png

 

If it helps. my source data (shift export) looks like this: 

2022-05-12 09_03_19-Utilisation Report V2 - Power BI Desktop.png


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.