Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi, Happy New year!
I want to get a solution for my model.
I assumed that the solution I want is about Semi-additive calculations. but it was different.
(I referenced this article from "daxpatterns.com")
So, If you can help me, I really appreciate that.
Here is a description of the question.
* Purpose: Usage status management of vacations
* Desired Result (Measure): YTD Number of used vacations at each time point (only for active employees at that time)
- You can check the Desired result from the underneath table.
* My model is here
* Here is the result table. and two measures(Columns) are like this
- Sum_Vac : Sum( 'Fact_Vacation'[#ofDays] )
- YTD_Vac : Calculate ( 'Fact_Vacation'[#ofDays], DATESYTD ('DIM_Calendar'[Cal_Date]) )
I want to get a measure for "Desired Result".
The important point for measure("Desired Result") is
after employee resigned (for this example: Emp_ID is "A120"),
the values that the resigned employee had used until 11, Oct 2019 should be extracted from "Desired Result" in columns "H" and "K".
Therefore, From 12, Oct 2019, the outstanding values for the active employees (for this example: Emp_ID is "A115") should be remaining.
If you need detailed data about it, I surely give it to you.
(Actually, I could not find the way of attaching files)
If you need additional explanations or Sources about this, please feel free to contact me.
And any recommendations about articles related to this concept are always welcome.
Thank you!
Solved! Go to Solution.
Hi @Anonymous
If I understand you correctly, you want to modify the existing YTD_Vac measure so that only Employees who have not resigned as at the currently filtered date are included.
You can do this by adding an additional filter such that Date_Resign is either blank or greater than the "currently filtered date".
We can choose how to define "currently filtered date", but I'm going to use the maximum visible date in the filter context.
With these assumptions, you could write a measure like this, making use of the existing YTD_Vac measure:
YTD_Vac for employees not yet resigned =
VAR MaxDate =
MAX ( Dim_Calendar[Cal_Date] )
RETURN
CALCULATE (
[YTD_Vac],
KEEPFILTERS (
OR (
ISBLANK ( Dim_EmpInfo[Date_Resign] ),
Dim_EmpInfo[Date_Resign] > MaxDate
)
)
)
You could also combine the logic into one measure (assuming can reference the Sum_Vac measure):
YTD_Vac for employees not yet resigned =
VAR MaxDate =
MAX ( Dim_Calendar[Cal_Date] )
RETURN
CALCULATE (
[Sum_Vac],
DATESYTD ( 'Dim_Calendar'[Cal_Date] ),
KEEPFILTERS (
OR (
ISBLANK ( Dim_EmpInfo[Date_Resign] ),
Dim_EmpInfo[Date_Resign] > MaxDate
)
)
)
Notes on the above:
Hopefully the above is useful and can be adapted to your model, but please post back if needed 🙂
Regards,
Owen
Hi @Anonymous
If I understand you correctly, you want to modify the existing YTD_Vac measure so that only Employees who have not resigned as at the currently filtered date are included.
You can do this by adding an additional filter such that Date_Resign is either blank or greater than the "currently filtered date".
We can choose how to define "currently filtered date", but I'm going to use the maximum visible date in the filter context.
With these assumptions, you could write a measure like this, making use of the existing YTD_Vac measure:
YTD_Vac for employees not yet resigned =
VAR MaxDate =
MAX ( Dim_Calendar[Cal_Date] )
RETURN
CALCULATE (
[YTD_Vac],
KEEPFILTERS (
OR (
ISBLANK ( Dim_EmpInfo[Date_Resign] ),
Dim_EmpInfo[Date_Resign] > MaxDate
)
)
)
You could also combine the logic into one measure (assuming can reference the Sum_Vac measure):
YTD_Vac for employees not yet resigned =
VAR MaxDate =
MAX ( Dim_Calendar[Cal_Date] )
RETURN
CALCULATE (
[Sum_Vac],
DATESYTD ( 'Dim_Calendar'[Cal_Date] ),
KEEPFILTERS (
OR (
ISBLANK ( Dim_EmpInfo[Date_Resign] ),
Dim_EmpInfo[Date_Resign] > MaxDate
)
)
)
Notes on the above:
Hopefully the above is useful and can be adapted to your model, but please post back if needed 🙂
Regards,
Owen
Thank you!!! Owen,
It nicely worked.
You inspired me with a good answer.
Regards,
Nash
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
25 | |
12 | |
9 | |
9 | |
9 |
User | Count |
---|---|
19 | |
14 | |
14 | |
13 | |
12 |