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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors