cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors