Select to view content in your preferred language

Create custom symbology

1145
5
Jump to solution
08-13-2024 01:30 AM
ndrogemuller1
Emerging Contributor

Hi, I have a road layer which has a "last maintained" attribute column showing date. How do I create symbology in Map Viewer which differentiates between a date less than 60 days from current date and more than 60 days from current date? 

Thanks.

0 Kudos
1 Solution

Accepted Solutions
RichardHowe
Frequent Contributor

Are you putting the expression in here:

RichardHowe_0-1723545400134.png


You would need to replace the "LastMaintained" with Grade_date (if you delete everything after the dot then it should show you a field list to pick from with the intellisense)

You can always click run inside the expression window to check it is giving you a viable answer.

I am also assuming that your "Grade_date" has a field type of "date", rather than being a string or a number.

Assuming all this is correct then you pick a style in your case "Types (unique symbol)" and then set your symbology - one for "Overdue" and one for "Not yet due"

View solution in original post

0 Kudos
5 Replies
RichardHowe
Frequent Contributor

Create a variable with your last maintained field and add 60 to it, then call Now() and compare them e.g.:

var LM = $feature.LastMaintained
var sixtydays = DateAdd(LM, +60, "days");
var today = Now()

If (sixtydays < today) {
return "Overdue"
} else {
    return "Not due"
}



This will give you two optional outputs to symbolise

0 Kudos
ndrogemuller1
Emerging Contributor

Thanks for the reply,

Being new to this, I've tried writing the above in the expression, with no luck. Mind you though the actual name of attribute is "Grade_date" which I put in. 

How exactly am I to write the expression?

0 Kudos
RichardHowe
Frequent Contributor

Are you putting the expression in here:

RichardHowe_0-1723545400134.png


You would need to replace the "LastMaintained" with Grade_date (if you delete everything after the dot then it should show you a field list to pick from with the intellisense)

You can always click run inside the expression window to check it is giving you a viable answer.

I am also assuming that your "Grade_date" has a field type of "date", rather than being a string or a number.

Assuming all this is correct then you pick a style in your case "Types (unique symbol)" and then set your symbology - one for "Overdue" and one for "Not yet due"

0 Kudos
ndrogemuller1
Emerging Contributor

Thanks Richard!

Turns out I had the field type as text string and not date. Fixed that and now all good.

Thanks!

RichardHowe
Frequent Contributor

No worries, glad it's sorted 😊

0 Kudos