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
Syndicate_Admin
Administrator
Administrator

Is there a way for me to calculate the days between two periods?

Good morning

I have to make a report to keep track of the signings and I need to put the days that people are on vacation.

For example, I have this data:

mariases94_0-1662108220319.png

I need that in a table I get the dates of the period "FromDate" to the "ToDate", that is to say the following:

mariases94_1-1662108390029.png

Is there a way for the dates between "FromDate" to "ToDate" to be broken down? Or that when I detect that the current day corresponds to a date of this period I dientify it and leave it as Vacation?

Thank you!

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

If your expected result is to create a calcualted table, please check the link down below.

https://jihwankimcscp.wixsite.com/supplychainflow/post/create-a-calculated-table-that-contains-activ...

 

Today morning, I wrote a short blog post that creates a calculated table by using GENERATE DAX function.

The structure of the origin table is the same (showing a start date and end date for each ID).

I hope this helps.

Thank you.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


@Syndicate_Admin

Hello!

It has worked, but if to the formula we use we need to add another variable, how would the formula be?

In other words, this is the formula that you have created:

Where _startdate =
MIN('Presence Control Exemptions'[FromDate])
Where _enddate =
Max ('Presence Control Exemptions'[ToDate])
Where _calendar =
SELECTCOLUMNS(CALENDAR(_startdate, _enddate), "@Date", [date])
Where _addemployee =
GENERATE(
_calendar,
FILTER(
'Presence Control Exemptions',
'Presence Control Exemptions'[FromDate] >= [@Date]
&& OR ('Presence Control Exemptions'[ToDate] >= [@Date], 'Presence Control Exemptions'[ToDate]= BLANK () )
)
)
RETURN
SUMMARIZE(_addemployee, [@Date], 'Presence Control Exemptions'[UserID])
But I need to add this other variable:
Where _exemption =
GENERATE(
_calendar,
FILTER(
'Presence Control Exemptions',
'Presence Control Exemptions'[FromDate] >= [@Date]
&& OR ('Presence Control Exemptions'[ToDate] >= [@Date], 'Presence Control Exemptions'[ToDate]= BLANK () )
)
)
But I don't know how to put it in the SUMARIZE at the end.... Can you help me?
So as one these two SUMMARIZE:
SUMMARIZE(_exemption, [@Date], 'Presence Control Exemptions'[ExTypeId])
SUMMARIZE(_addemployee, [@Date], 'Presence Control Exemptions'[UserID])
Thanks a lot!

Hi,

Thank you for your feedback, but sorry that I am not sure whether I understood your last question correctly.

Could you please try something like below?

 

SUMMARIZE(_exemption, [@Date], 'Presence Control Exemptions'[ExTypeId], 'Presence Control Exemptions'[UserID])

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.