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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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