cancel
Showing results 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

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:

 Name Given Name Month Year Smith John 4 2021 Smith John 5 2021 Smith John 6 2021 Smith John 7 2021 Muller Alex 5 2021 Muller Alex 6 2021 Davis Sam 7 2021

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
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])))``

4 REPLIES 4
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])))``

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)))

Helper I

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?

Helper I

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.