Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi, I have a dataset of employees working on month-to-month basis on different projects. Every row of the dataset uniquely identifies an employee working on one project in one month. Furthermore, his revenue and allocation on that project for that month is also recorded in that row (Also, for one month, the cummulative sum of the allocation will never exceed "1" for any employee)
The dataset looks something like this,
Date | Emp Code | Project Code | Allocation | Revenue |
11/1/2022 0:00 | 1 | A | 1 | 1160 |
12/1/2022 0:00 | 1 | A | 1 | 1160 |
1/1/2023 0:00 | 1 | A | 1 | |
2/1/2023 0:00 | 1 | A | 1 | |
3/1/2023 0:00 | 1 | A | 1 | |
11/1/2022 0:00 | 2 | B | 0.4 | 5544 |
11/1/2022 0:00 | 2 | C | 0.6 | 2000 |
12/1/2022 0:00 | 2 | B | 0.6 | 4032 |
12/1/2022 0:00 | 2 | C | 0.3 | 1000 |
1/1/2023 0:00 | 2 | B | 0.6 | |
1/1/2023 0:00 | 2 | C | 0.4 | |
2/1/2023 0:00 | 2 | B | 0.6 | |
2/1/2023 0:00 | 2 | C | 0.4 | |
3/1/2023 0:00 | 2 | B | 0.6 | |
3/1/2023 0:00 | 2 | C | 0.4 | |
11/1/2022 0:00 | 3 | B | 1 | 4788 |
12/1/2022 0:00 | 3 | B | 0.75 | 4284 |
1/1/2023 0:00 | 3 | B | 1 | |
2/1/2023 0:00 | 3 | B | 1 | |
3/1/2023 0:00 | 3 | B | 1 | |
11/1/2022 0:00 | 4 | Bench | 1 | 0 |
12/1/2022 0:00 | 4 | Bench | 1 | 0 |
1/1/2023 0:00 | 4 | B | 1 | |
2/1/2023 0:00 | 4 | B | 1 | |
3/1/2023 0:00 | 4 | B | 0.8 |
I need to calculate the Projected Revenue of all the employees for the current (Today()) and the next Months in the dataset. What I am trying to achieve is to create a new Calculated Column in the dataset (because that's what I believe should be done).
The logic for calculating the Projected Revenue of the Current and Next Month is as follows (this logic will give same value for all the next months, barring any exceptional case)
The problem that I am facing is this actually requires me to use Multiple values from current row as well as the previous Row. What I tried to do was to use Lookupvalue function. I tried to get the current row's Emp_ID, Date and Project_Code (because that uniquely identifies a record) and using that, I tried to look up the Revenue and Allocation Value by subtracting one month from the Date. However, it didn't work for me and gave me an error that I was looking at multiple records (not sure why as my dataset was quite huge so I couldn't figure it out)
Then, I also tried to use Calculate function to get the value of Last Month's Revenue and fill up the whole new column with that value (for now), but again this acted differently. It only filled up the values for the Last Month, and not for the months I wanted it to fill the values for. This is the measure I tried
Projected Revenue =
var last_row_year = YEAR(EDATE(TODAY(), -1))
var last_row_month = MONTH(EDATE(TODAY(), -1))
var value_amount =
CALCULATE(
SUM('data'[Revenue]),
YEAR(data[Date]) = last_row_year,
MONTH(data[Date]) = last_row_month
)
RETURN
value_amount
But it didn't work for me and only filled up the values for December 2022
Can anyone help me out in this?
You can download the Power BI File from here if needed: https://drive.google.com/file/d/1YGXxHZqdZO9IwFmmkf1dSrv_b9LSpdO6/view?usp=sharing
Thanks a lot in advance!
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
25 | |
20 | |
18 | |
18 | |
15 |
User | Count |
---|---|
38 | |
20 | |
19 | |
16 | |
10 |