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.
Hi everyone
I need help with a calculated column formula :
I have a table with three columns : names of employees, current assignment and current month
[Employee] [Assignment] [Month]
EmployeeA NewYork January
EmployeeB LosAngeles January
EmployeeC Miami January
EmployeeA LosAngeles February
EmployeeB NewYork February
EmployeeC Miami February
I need to track changes in assignments month to month. In the current example, in February, Employee A was reassigned to the LosAngeles office and Employee B to the NewYork office.
To do this, I would like to add a calculated column in the table that would return on each row the value of the assingment of the previous month for the same employee. For example :
[Employee] [Assignment] [Month] [Newcalculatedcolumn]
EmployeeB NewYork February LosAngeles
On a given month, an employee can only have one assignment; data is clean in this regard.
I've been through the various forums for hours and was unsuccessful with the calculate, filter and date functions. Most examples show how to compute a YTD and LYTD sum, but I couldn't find how to return a text value. I'm a complete beginner. If anyone could help, that would be much appreciated.
Thanks a lot.
Solved! Go to Solution.
If you use a number-representation for your months, it's relatively easy:
1) Add a column where you calculate the previous month (-1)
2) Merge the table with itself on the 2 number columns: Current month with previous month per employee and expand the location.
Here is a short video:
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @arnaudrueff,
You can also achieve that in View mode using DAX.
First, change the [Month] column to numeric.
Month No = SWITCH ( 'Search Value'[Month], "January", 1, "February", 2, "March", 3, "April", 4, "May", 5, "June", 6, "July", 7, "Auguest", 8, "September", 9, "October", 10, "November", 11, "December", 12 )
Add a calculate column to display previous month number.
Previous Month No = 'Search Value'[Month No]-1
Use a LookUpValue function to fetch the value of assingment of the previous month for the same employee.
Previous Assignment = LOOKUPVALUE ( 'Search Value'[Assignment], 'Search Value'[Month No], 'Search Value'[Previous Month No], 'Search Value'[Employee], 'Search Value'[Employee] )
Best regards,
Yuliana Gu
If you use a number-representation for your months, it's relatively easy:
1) Add a column where you calculate the previous month (-1)
2) Merge the table with itself on the 2 number columns: Current month with previous month per employee and expand the location.
Here is a short video:
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
117 | |
104 | |
77 | |
73 | |
52 |
User | Count |
---|---|
145 | |
109 | |
108 | |
90 | |
64 |