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

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.

Reply
Anonymous
Not applicable

Define a value depending on a range of dates

Dear all,

I´m struggling with a case that I´ll try to show on the example below.

I have two different tables:

 

Table: SAP_HR-Z_PA2001 - shows each vacation period that an employee has taken. Example of one employee:

User IDBeginning of VacationsEnd of Vacations
744721/12/201530/12/2015
744710/02/201629/02/2016
744701/03/201730/03/2017
744705/02/201806/03/2018

 

Table: SAP_HR-Z_PA2006 - shows the range of dates when the employee has the right to take the leave (in Brazil, for every year of work, the employee has the right (and obligation) to take 30 days of absence in the following year). Example of the same Employee:

User IDInitial PeriodFinal PeriodDate Limit
744710/03/201409/03/201509/03/2016
744710/03/201509/03/201609/03/2017
744710/03/201609/03/201709/03/2018

 

This means that, looking at the first line, from March 9th 2015 to March 9th 2016 has to complete 30 days of vacations, that can be split within 3 different periods.

 

So, what I´m trying to achieve is the tell, on the first table, which of the corresponding period the employee has taken its absence:

User IDBeginning of VacationsEnd of VacationsVacation Period
744721/12/201530/12/20152014/2015
744710/02/201629/02/20162014/2015
744701/03/201730/03/20172015/2016
744705/02/201806/03/20182016/2017

 

If they were in the same table, I would do something like

 

IF ([End of Vacations] > [Final Period] && [End of Vacations] < [Date Limit]

  THEN YEAR([Initial Period]) & "/" & YEAR(Final Period])

)

 

Thank you for any help.

Eduardo

3 REPLIES 3
Anonymous
Not applicable

I´m trying this formula, but it´s returning me "DAX comparison operations do not support comaring values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values."

 

Vacation Period = 
var currentEmployee = 'SAP_HR-Z_PA2001'[User ID]
var vacationEnd = 'SAP_HR-Z_PA2001'[End of Vacations]
var vacationPeriod = CALCULATE(
			FIRSTNONBLANK('SAP_HR-Z_PA2006'[Final Period];1)
			;FILTER('SAP_HR-Z_PA2006';'SAP_HR-Z_PA2006'[User ID] = currentEmployee 
			     && 'SAP_HR-Z_PA2006'[Final Period] <= vacationEnd 
			     && 'SAP_HR-Z_PA2006'[Date Limit] >= vacationEnd
			     )) 
return
            IF(vacationPeriod = "";"";vacationPeriod)

@Anonymous,

 

You may use ISBLANK Function and BLANK Function instead of the empty string.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you. It solved me the error type, but now gives me "A circular dependency was deteced: SAP_HR-Z_PA2001[Vacation Period], 1bda6a34-e63f-[...], SAP_HR-Z_PA2001[Vacation Period]

 


wrote:

@Anonymous,

 

You may use ISBLANK Function and BLANK Function instead of the empty string.


 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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