cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ikelaiah
Frequent Visitor

Get/count id of employee promoted in a timeframe


Hi,

 

I have the following data.

 

+-----+----------------+--------------+----------------+-----------------+
| id  | contract_start | contract_end | contract_level | contract_reason |
+-----+----------------+--------------+----------------+-----------------+
| 111 | 2020-10-01     | 2020-11-01   |              2 | start           |
| 112 |  2020-10-15    | 2020-11-15   |              1 | start           |
| 111 | 2020-12-01     | 2021-01-01   |              2 | renew           |
| 112 |  2020-12-15    | 2021-01-15   |              1 | renew           |
| 111 | 2021-02-01     | 2021-03-01   |              2 | renew           |
| 112 |  2021-02-15    | 2021-03-15   |              1 | renew           |
| 111 | 2021-04-01     | 2021-05-01   |              3 | renew           |
| 112 |  2021-04-15    | 2021-05-15   |              1 | renew           |
| 111 | 2021-06-01     | 2021-07-01   |              3 | renew           |
| 112 |  2021-06-15    | 2021-07-15   |              2 | renew           |
+-----+----------------+--------------+----------------+-----------------+

 

What would be the best way to get/count id of employee promoted in 2021-2021 as indicated in the contract_level field?

Shall I approach this with Power Query or DAX?

Thank you.

1 ACCEPTED SOLUTION
aj1973
Community Champion
Community Champion

Hi @ikelaiah 

here is the DAX formula :

aj1973_0-1624107787746.png

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

View solution in original post

5 REPLIES 5
ryan_mayu
Super User II
Super User II

@ikelaiah 

You can try this

Promoted = 
VAR _start=MINX(FILTER('Table',YEAR('Table'[Contract_start])=2021),'Table'[Contract_start])
VAR _startlevel=maxx(FILTER('Table','Table'[Contract_start]=_start),'Table'[Contract_level])
VAR _end=MAXX(FILTER('Table',YEAR('Table'[Contract_start])=2021),'Table'[Contract_start])
VAR _endlevel=maxx(FILTER('Table','Table'[Contract_start]=_end),'Table'[Contract_level])
return if(_endlevel<>_startlevel,"Yes","No")


_COUNT = COUNTAX(VALUES('Table'[ID]),[Promoted]="Yes")

1.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu , thanks for showing me this approach of using MINX and MAXX.

aj1973
Community Champion
Community Champion

Hi @ikelaiah 

here is the DAX formula :

aj1973_0-1624107787746.png

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

View solution in original post

ikelaiah
Frequent Visitor

@aj1973 , thanks for this approach. I didn't think I could use DICTINCTCOUNT on it. So it gets me the count. Many thanks.

aj1973
Community Champion
Community Champion

Many weolcomes to @ikelaiah 

Please mark this thread as accepted for the rest of the community.

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors