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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filling in the icon in...
Power Apps
Unanswered

Filling in the icon in gallery according to the calculation of the difference of days

(0) ShareShare
ReportReport
Posted on by 361

I need to fill the fill of this icon according to the text of each item, for example:

 

If thisItem = Diario, subtract the date below (in the case of the image 07.06) and the color will turn yellow if it is more than 24 hours (Daily). If it is less than 24 hours - or 1 day -, leave it green.

 

If ThisItem = Semanal, subtract the date below (in the case of the image 07.06) and the color will turn yellow if it is more than 168 hours (Weekly). If it's less than 168 hours - or 7 days - leave it green.

 

If ThisItem = Mensal, subtract the date below (in the case of the 07.06 image) and the color will turn yellow if it is more than 720 hours (Monthly). If it's less than 720 hours - or 30 days - leave it green. I think I managed to sum it up... It's like a "warning"

 

AND MY CODE IS APPARENTLY CORRECT BUT IT SEEMS THAT IT IS NOT CARRYING OUT THE TIME CALCULATION

 

Joaoandrebs_0-1687876140818.png LABEL 9 IN RED informing the date.

 

my code: 

 

Switch(

ThisItem.Frequencia;

"Diario";

If(DateDiff(Now();Label9.Text; TimeUnit.Hours) <= 24; Color.Green;Color.Orange);

"Semanal"; 

If(DateDiff(Now();Label9.Text; TimeUnit.Hours) <= 168; Color.Green;Color.Orange);

"Mensal"; 

If(DateDiff(Now();Label9.Text; TimeUnit.Hours) <= 720; Color.Green;Color.Orange)

)

 

ThisItem.Frequencia = Column from SP List that contains "Diario", "Semanal", "Mensal" 

Categories:
I have the same question (0)
  • madlad Profile Picture
    2,637 Moderator on at

    Inside of Switch(), you need to use commas not semicolons i think

  • madlad Profile Picture
    2,637 Moderator on at

    Ignore that reply, I just realized this is a regional syntax thing, and is different for me than you

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Try this

    Switch(
    
    ThisItem.Frequencia;
    
    "Diario";
    
    If(DateDiff(Now();DateTimeValue(Label9.Text); TimeUnit.Hours) <= 24; Color.Green;Color.Orange);
    
    "Semanal"; 
    
    If(DateDiff(Now();DateTimeValue(Label9.Text); TimeUnit.Hours) <= 168; Color.Green;Color.Orange);
    
    "Mensal"; 
    
    If(DateDiff(Now();DateTimeValue(Label9.Text); TimeUnit.Hours) <= 720; Color.Green;Color.Orange)
    
    )
  • TheRobRush Profile Picture
    11,128 Moderator on at

    One note, if oyu need Now() constantly updating on same page without reloading the page etc, place a timer in your app with a duration of 1, and autostart to on, repeat to on, auto pause to off, then make its ontimerend Set(currentTime, Now()) and then reference currentTime instead of Now()

  • Joaoandrebs Profile Picture
    361 on at

    @TheRobRush 

     

    The code didn't work, but it didn't report any errors...
    I don't know what it could be 😞

  • Verified answer
    TheRobRush Profile Picture
    11,128 Moderator on at

    place three labels next to this.

     

    make one

    DateTimeValue(Label9.Text)

    and second

    Now()

     

    and third

    DateDiff(Now();DateTimeValue(Label9.Text); TimeUnit.Hours)

     

    and make sure all return the values you expected they would

  • Joaoandrebs Profile Picture
    361 on at

    @TheRobRushI tried what you recommended and showed me a detail, the result of the difference was coming negative, I reversed the order and put the now on the other side of the formula and it worked!!!

    u are the man!

    DateDiff(DateTimeValue(Label9.Text);Now(); TimeUnit.Hours)

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard