Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
bkr
Helper I
Helper I

Calculate Fluctuation Table from Name list and month

Dear DAX cracks,

 

I have a list of employees in our facility that is updated every month. In a reduced form, it looks like this:

NameGiven NameMonthYear
SmithJohn42021
SmithJohn52021
SmithJohn62021
SmithJohn72021
MullerAlex52021
MullerAlex62021
DavisSam72021

As you can see, Alex Muller joined in May and Sam Davis was hired in July.

 

I was asked to prepare a calculated table that shows the new hires based on a time slicer. E.g. If I wanted to show the additional hires from between April and August July, it should output Alex Muller and Sam Davis. In another calculated table I'd like to have the exits in a certain time period.

 

My idea would be to calculate 2 interim tables, one containing the facts of the the starting month and the other having the end month data and then do something like a right outer join with the two interim tables in the first case and a left outer join in the second. But I don't understand how to achieve this in DAX. Any advice? Thank you!

1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@bkr 
"E.g. If I wanted to show the additional hires from between April and August July, it should output Alex Muller and Sam Davis." 


I guess you meant if you choose May to July here, because John Smith is also a new in April. I create a calculated table to achieve this, basically you just need find the join month of each people. 

Table 2 = SUMMARIZE('Table',[Given Name],[Name],[Year],"Join Month",CALCULATE(MIN('Table'[Month]),ALLEXCEPT('Table','Table'[Name])))

 

Vpazhenmsft_0-1636426212604.png

 

 

View solution in original post

4 REPLIES 4
V-pazhen-msft
Community Support
Community Support

@bkr 
"E.g. If I wanted to show the additional hires from between April and August July, it should output Alex Muller and Sam Davis." 


I guess you meant if you choose May to July here, because John Smith is also a new in April. I create a calculated table to achieve this, basically you just need find the join month of each people. 

Table 2 = SUMMARIZE('Table',[Given Name],[Name],[Year],"Join Month",CALCULATE(MIN('Table'[Month]),ALLEXCEPT('Table','Table'[Name])))

 

Vpazhenmsft_0-1636426212604.png

 

 

amitchandak
Super User
Super User

@bkr , You can not use slicer values in a calculated table. But you can do it in a measure. Please make sure you have date and full name or ID

 

sales =
var _max = maxx(allselected('Date'),'Date'[Date])
var _min = minx(allselected('Date'),'Date'[Date])
var _hire = calculate(Min(Table[Date]), allexcept(Table, Table[Full Name]) )
return
calculate(countx(filter(values(Table[Full name]) , _hire <=_max && _hire >= _min)))

Thank you very much! I tried to transfer your solution on my data model. However, it's asking for another argument for the countx function in the last line. Is there anything missing here?

Ok, I think I got what wou wanted to write - I assume the last line should read
calculate(countx(filter(values(Table[Full name]) , _hire <=_max && _hire >= _min), Table[Full Name]))

 

This gives me a number. But what I need is a list of the Names of the new hires.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

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