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

How to replicate bwllow formula in power bi

IF(DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])>5
AND DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])<=10 )
then
'6-10 Days'
ELSEIF (DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])>=4
AND DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])<=5)
then
'4-5 Days'
ELSEIF (DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])>=0
AND DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])<=3 )
then
'0-3 Days'
ELSE
'>10 DAYS'

END

1 ACCEPTED SOLUTION

Few ways to do this - could always just make a custom column finding the date difference and then grouping on the results, or make a column like this:

 

groupme.PNG

 

Could probably do it as a measure as well

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

IF(DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])>5
AND DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])<=10 )
then
'6-10 Days'
ELSEIF (DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])>=4
AND DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])<=5)
then
'4-5 Days'
ELSEIF (DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])>=0
AND DATEDIFF('day',[Min StartDate Per Payload],[Max EndDate per PayloadID])<=3 )
then
'0-3 Days'
ELSE
'>10 DAYS'

END

Few ways to do this - could always just make a custom column finding the date difference and then grouping on the results, or make a column like this:

 

groupme.PNG

 

Could probably do it as a measure as well

ibarrau
Super User
Super User

Hi there. The syntax in DAX should be like this 

 

How it works "IF(Condition, TRUE, FALSE)"

 

IF(AND(Condition1, Condition2), "ResultTrue", IF(AND(Condition1, Condition2), "ResultTrue", IF( ....  ) ) )

Check that the FALSE is your ELSEIF statement.

 

You can also do it on Power Query M. But it could be more complex the change due to Datediff function.

 

Regards,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

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.