Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Good morning,
Qlikview user here trying to move to Power BI.
Need to define a calculated measure to count active workforce based on selected year.
Name Hire Date Termination date
Name 1 January 2, 2010
Name 2 Februray 5, 2010
Name 3 April 2, 2011
Name 4 April 15, 2012
Name 5 March 5, 2013
Name 6 March 18, 2014 January 16, 2017
Name 7 Sept 15, 2015
Name 8, January 7, 2016 February 8, 2017
Name 9 February 25, 2017
Having above sample data.
If i choose year 2017, my active workforce is 8 as 1 resigned in Feb,
If i choose year 2016, my active worforce is 8 as Name 8 and Name 6 resigned in 2017
Many thanks
Solved! Go to Solution.
Hi @CJ_96601,
Suppose the data table is named as 'Workforce', also you have an extra table which lists unique year values named as 'Year Table'.
Please refer to below measure:
Count workforce =
CALCULATE (
COUNT ( Workforce[Name] ),
FILTER (
Workforce,
Workforce[Hire Date].[Year] <= MAX ( 'Year Table'[YearSelection] )
&& (
Workforce[Termination Date] = BLANK ()
|| Workforce[Termination Date].[Year] > MAX ( 'Year Table'[YearSelection] )
)
)
)
Best regards,
Yuliana Gu
Hi @CJ_96601,
Using a calendar table also applies to this scenario. Please remove the relationship between these two tables. If you cann't remove the relationship, please create another unrelated date table like what I have did.
Regards,
Yuliana Gu
Hi @CJ_96601,
Suppose the data table is named as 'Workforce', also you have an extra table which lists unique year values named as 'Year Table'.
Please refer to below measure:
Count workforce =
CALCULATE (
COUNT ( Workforce[Name] ),
FILTER (
Workforce,
Workforce[Hire Date].[Year] <= MAX ( 'Year Table'[YearSelection] )
&& (
Workforce[Termination Date] = BLANK ()
|| Workforce[Termination Date].[Year] > MAX ( 'Year Table'[YearSelection] )
)
)
)
Best regards,
Yuliana Gu
hi @v-yulgu-msft,
Thank you for your response.
I appreciate if you could send your sample pbix file.
Furthermore, i dont have a table with unique list of year, i use calendar.
The workforce table is link to calendar. Active relation is HIREDate, inactive is Termination Date.
Regards
Hi @CJ_96601,
Using a calendar table also applies to this scenario. Please remove the relationship between these two tables. If you cann't remove the relationship, please create another unrelated date table like what I have did.
Regards,
Yuliana Gu
Thanks @v-yulgu-msft,
You're saying there is no need to establish a relationship between calendar and my workforce file?
If i may ask what is the use of calendar in power bi.
My apology, i'm new in power bi
Regards,
Hi,
Please provide sample on how to count those who were terminated based on year selection.
Is there a way, if i need to filter based on month / year or quarter / year
Regards,
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 47 | |
| 44 | |
| 40 | |
| 18 | |
| 18 |
| User | Count |
|---|---|
| 70 | |
| 68 | |
| 33 | |
| 32 | |
| 32 |