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

Change the interval in datediff by using the parameter?

Hello,

 

It is possible to easily change the output from the datediff formula from weeks to days? 

I tried to replace the interval in the measure with the parameter ("WEEK" or "DAY") however, the formula did not accept that. 

I have a few calculations and a few graphs and hoped it can be done quite quickly instead of using bookmarks and duplicating the graphs with calculations.

 

I would be grateful if anyone can help. 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

One of ways to achieve this is,

- create a measure using DATEDIFF with DAY parameter.
- define how the business wants to see numbers of WEEK. For instance, is 8 days is one week or two weeks? I am not sure if the business wants to see the result like 1.15 weeks, but it depends on the business's requirement.

- create a slicer that shows DAY or WEEK.
- create an additional measure that describes, if DAY is selected, then show the result of the measure. If WEEK is selected, then divide the result of the measure by 7, and then add additional logic to the measure that only shows integer (depends on the business requirement).

 

I hope this helps.

Thanks.

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


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

One of ways to achieve this is,

- create a measure using DATEDIFF with DAY parameter.
- define how the business wants to see numbers of WEEK. For instance, is 8 days is one week or two weeks? I am not sure if the business wants to see the result like 1.15 weeks, but it depends on the business's requirement.

- create a slicer that shows DAY or WEEK.
- create an additional measure that describes, if DAY is selected, then show the result of the measure. If WEEK is selected, then divide the result of the measure by 7, and then add additional logic to the measure that only shows integer (depends on the business requirement).

 

I hope this helps.

Thanks.

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


Thank you for this workaround. It was inspirational, and confirmed that there is no shortcut to do it 🙂 

 

I have created two DATEDIFF measures, with Day and Week intervals, and then added both to the Field parameter and used the parameter in the visualization.  

 

The weak point is that I have to duplicate each measure, in case there are several DATEDIFF.

 

Thank you!!

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.