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
AndreaSo
Frequent Visitor

Calculate half a year intervals between two different dates

Hi

 

I am using DATEIFF function to create calculated column to calculate time interval between two days. May I ask if you can help me how can I calculate half a year intervals? The function only allows me for Quarters.

 

I would appreciate any other suggestions on how to calculate the column.

 

Function I am using:

YearsBetween column =
DATEDIFF(
    ('Blade List + Findings'[Comm End Date]),
    ('Blade List + Findings'[SG145 Finding register.Inspection Date]),YEAR
 
)
 
Thank you.
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @AndreaSo ,

 

For this you just need to take the value and multiply or divide by the corresponding values so if you use the year has parameter in datediff multipli by 2, if it's quarters divide by 2, if its months divide by 6. you measure should be similar to this:

 

YearsBetween column =
DATEDIFF(
    ('Blade List + Findings'[Comm End Date]),
    ('Blade List + Findings'[SG145 Finding register.Inspection Date]),YEAR
 ) * 2
 
Be aware that you may need to adjust the rounding.

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @AndreaSo ,

 

For this you just need to take the value and multiply or divide by the corresponding values so if you use the year has parameter in datediff multipli by 2, if it's quarters divide by 2, if its months divide by 6. you measure should be similar to this:

 

YearsBetween column =
DATEDIFF(
    ('Blade List + Findings'[Comm End Date]),
    ('Blade List + Findings'[SG145 Finding register.Inspection Date]),YEAR
 ) * 2
 
Be aware that you may need to adjust the rounding.

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



pratyashasamal
Super User
Super User

Hi @AndreaSo ,

You can use MONTH as an interval. For example:-
EVALUATE VAR StartDate = DATE ( 20190701 ) VAR EndDate = DATE ( 20211231 ) RETURN { ( "Year"DATEDIFF ( StartDate, EndDate, YEAR ) ), ( "Quarter"DATEDIFF ( StartDate, EndDate, QUARTER ) ), ( "Month"DATEDIFF ( StartDate, EndDate, MONTH ) ), ( "Week"DATEDIFF ( StartDate, EndDate, WEEK ) ), ( "Day"DATEDIFF ( StartDate, EndDate, DAY ) ) }
Datediff give you these interval options :-
 - SECOND
- MINUTE
- HOUR
- DAY
- WEEK
- MONTH
- QUARTER
- YEAR
You can refer to this link for more information :-
https://learn.microsoft.com/en-us/dax/datediff-function-dax

Thanks,
Pratyasha Samal
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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.