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
Zaidan30
Regular Visitor

Headcount on dashboard is not the same when i'm filtering a month and year.

Hello everyone, 

 

I'm working on excel power query and i have measures of headcount, hires, terminations etc. I created a dashboard of all these KPIs but when i filter the dates that is, if i select 2024 and month April or May the headcount and all other KPIs are becoming as Headcount - 46, Hires - 2, Terminated - 7 etc. Where as the total number by the end or the month must be 3702 in April and 3828 in May. Here are the screen shots. 

Zaidan30_0-1745596372132.png

This is before any filters


Zaidan30_1-1745596427658.png

This is after i select the filters ie, May 2024

 

Please let me know where i'm going wrong? I have created the date_table[Date] and connected it to Hire date and termination date in my data sheet. 

1 ACCEPTED SOLUTION

@Zaidan30 Perfect! Thanks for the detailed information. I did it like the following. PBIX is attached below signature.

Measure = 
    VAR __MaxDate = MAX( 'Dates'[Date] )
    VAR __Table = FILTER( ALL( 'Table' ), [Hire Date] <= __MaxDate )
    VAR __Table2 = FILTER( ALL( 'Table' ), [Termination Date] <= __MaxDate && [Termination Date] <> BLANK() )
    VAR __Result = COUNTROWS( __Table ) - COUNTROWS( __Table2 )
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Zaidan30
Regular Visitor

Hello @Greg_Deckler 

 

Thank you so much for your reply. Let me share all the points with you. Here's the data that i'm working on, 

 

EMP IDNameStart DateTermination Date
1Matthieu1/1/2024 
2Paul3/27/20244/30/2024
3Rémi3/27/20244/30/2024
4Guillaume1/1/2024 
5Isabelle1/1/2024 
6Agnès1/1/2024 
7Amelie9/9/2024 
8Anne Sophie1/1/2024 
9Olivier1/1/2024 
10Brice4/22/202412/31/2024
11Antoine1/1/2024 
12Dorine1/1/2024 
13Ophelie1/1/2024 

 

My expected output is, 

 

Expected output: 
Headcount10
Terminated 3

 

Problem I'm having in the dashboard: 

 

* When I'm using a filter to have the total HC until this particular month in this case September 2024 for eg: If i click September 2024 slicer I'm getting information of September as just 1 Where as the total Headcount until the end of Sep 2024 is 11.

 

*Here are the screen shots of the measures i have created.

 

Zaidan30_0-1745679327625.png

Zaidan30_1-1745679352117.pngZaidan30_2-1745679373093.png

 

Here's the screenshot of the connection beween HR data and Date table. i have connected Hire date and termination date with Date_Table [Date]

 

Zaidan30_3-1745679508098.png

I hope this helps. Thank you so mich in advance for your help. 

Zaidan30
Regular Visitor

Hello @Greg_Deckler ,

 

Thank you so much for your message. My apologies for not being clear. Here's all he information you asked for, 

 

Below is the data that i'm working on which had 5000 rows. 

 

SSO with ZeroNameHire DateTermination Date
1Matthieu1/1/2024 
2Paul3/27/20244/30/2024
3Rémi3/27/20244/30/2024
4Guillaume1/1/2024 
5Isabelle1/1/2024 
6Agnès1/1/2024 
7Amelie9/9/2024 
8Anne Sophie1/1/2024 
9Olivier1/1/2024 
10Brice4/22/202412/31/2024
11Antoine1/1/2024 
12Dorine1/1/2024 
13Ophelie1/1/2024 

 

I have an overall expected ouput when i dont use any filters. 

 

Expected output: 
Headcount10
Terminated 3

 

Problem I'm having in the dashboard:

 

* When I'm using a filter to have the total HC until this particular month in this case September 2024 for eg: If i click September 2024 slicer I'm getting information of September as just 1 Where as the total Headcount until the end of Sep 2024 is 11.

*Here are the screen shots of the measures i have created.

 

Zaidan30_0-1745673407122.pngZaidan30_1-1745673430531.pngZaidan30_2-1745673461401.png

 

My date table is connected to Hires date and termination date with "Date": 

 

Zaidan30_3-1745673616227.png

 

I hope this helps to understand better. 🙂 

 

@Zaidan30 Perfect! Thanks for the detailed information. I did it like the following. PBIX is attached below signature.

Measure = 
    VAR __MaxDate = MAX( 'Dates'[Date] )
    VAR __Table = FILTER( ALL( 'Table' ), [Hire Date] <= __MaxDate )
    VAR __Table2 = FILTER( ALL( 'Table' ), [Termination Date] <= __MaxDate && [Termination Date] <> BLANK() )
    VAR __Result = COUNTROWS( __Table ) - COUNTROWS( __Table2 )
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hello @Greg_Deckler ,

 

I'm so happy you solved my problem. You're really the best. i was working to solve this problem from almost 3 days before posting my request here. Thank you sooo sooo much for your help. 🙂 🙂 

 

Greg_Deckler
Super User
Super User

@Zaidan30 Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 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.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors