web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Priority field failing...
Power Apps
Answered

Priority field failing to default based on x2 date range options

(1) ShareShare
ReportReport
Posted on by

Hi all,

 

I have a new form capture. The business wants a priority drop down field in the form to populate based on x2 date picker fields (proposed start and finish dates).

 

I have the following, which is working up until 0-1 days, but then the code fails from level 4 through 6. Any suggestions how to tweak?

 

With(
 {StartDate:DataCardValue44.SelectedDate,
 EndDate:DataCardValue45.SelectedDate},
 If(IsBlank(DataCardValue44.SelectedDate) && IsBlank(DataCardValue45.SelectedDate),{Value:""},
 DateDiff(StartDate,EndDate,TimeUnit.Days)=0 Or 1,{Value:"3 - High"},
 DateDiff(StartDate,EndDate,TimeUnit.Days)<=7,{Value:"4 – Medium"},
 DateDiff(StartDate,EndDate,TimeUnit.Days)<=31,{Value:"5 – Low"},
 DateDiff(StartDate,EndDate,TimeUnit.Days)>=32,{Value:"6 – As agreed"})
 )

 

It should be:

0-1 days = high

2-7 days = medium

8-31 days = low

>32 days = As agreed

 

Thanks,

 

DW

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    Hi @DGWolfe ,

    Try this format

    If(
     IsBlank(DataCardValue44.SelectedDate) ||
     IsBlank(DataCardValue45.SelectedDate),
     {Value: Blank()},
     With(
     {
     wDays:
     DateDiff(
     DataCardValue44.SelectedDate,
     DataCardValue45.SelectedDate,
     TimeUnit.Days
     )
     },
     {
     Value:
     If(
     wDays = 0 || wDays = 1,
     "3 - High",
     wDays <=7, 
     "4 – Medium",
     wDays <=31, 
     "5 – Low",
     "6 – As agreed"
     )
     }
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Verified answer
    DGWolfe Profile Picture
    on at

    @WarrenBelz legend as always! Thank you. Much cleaner and works perfectly. 🙂

  • DGWolfe Profile Picture
    on at

    @WarrenBelz sorry, I have now been asked to change the above so that the priority should calculate based on the number of days from today.

     

    Would the following work: 

    If(
     IsBlank(DataCardValue44.SelectedDate) ||
     IsBlank(DataCardValue45.SelectedDate),
     {Value: Blank()},
     With(
     {
     wDays:
     DateDiff(
     Today(),
     DataCardValue45.SelectedDate,
     TimeUnit.Days
     )
     },
     {
     Value:
     If(
     wDays = 0 || wDays = 1,
     "3 - High",
     wDays <=7, 
     "4 – Medium",
     wDays <=31, 
     "5 – Low",
     "6 – As agreed"
     )
     }
     )
    )

    I tried substituting the so that I had Today() and datacard44 (start date), but it fails. 

     

    Any help would be appreciated.

     

    DW
     

  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    Hi @DGWolfe 

    Depends which way around those dates are which is the earliest ?

    Try the other way around.

  • DGWolfe Profile Picture
    on at

    @WarrenBelz it actually was working, I just needed to fill in the second date range to trigger the calcs. Thanks 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard