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
ikelaiah
Advocate I
Advocate I

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
Super User

@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

@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
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.