Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- SAS Viya
- /
- Visual Analytics
- /
- SAS Visual Analytics, Possibility of applying rules by category

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

☑ This topic is **solved**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 06-28-2024 09:48 AM
(362 views)

Hi there,

Pls assist, thanks in advance.

I am applying colour coding based on the % of status (status has 3 categories in it - Planned, Completed, Overdue). Now the rules are applied as a whole. Is there a way to include colour coding by status.

current scenario:

If status:

95% - 100% green |

75% - <95% amber |

<75% red |

Is it possible to apply rules based on status:

if status="Completed" and percentage ge 75% then green.

if status="Overdue" and percentage le 5% then green.

...and so on.

Thanks,

RP

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hey @prsr! I believe you can achieve this by creating a calculated item that flags a 1 or 0 if the aggregated value is higher than the expected value for that specific category. Let's consider this with sashelp.cars: we have a bar chart with average horsepower by origin. If the average horsepower for Asian vehicles is > 150, we want the bar to be red. Let's create a calculation that does this:

if( Avg(ByGroup, if(Origin = 'Asia') return Horsepower else .) ) > 150 return 1 else 0

Now we can add this calculation as a rule to our bar chart. Based on our calculation, this can only be a 1 or 0 for Asian vehicles.

And now if we look at our bar chart, only Asia is highlighted red.

2 REPLIES 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hey @prsr! I believe you can achieve this by creating a calculated item that flags a 1 or 0 if the aggregated value is higher than the expected value for that specific category. Let's consider this with sashelp.cars: we have a bar chart with average horsepower by origin. If the average horsepower for Asian vehicles is > 150, we want the bar to be red. Let's create a calculation that does this:

if( Avg(ByGroup, if(Origin = 'Asia') return Horsepower else .) ) > 150 return 1 else 0

Now we can add this calculation as a rule to our bar chart. Based on our calculation, this can only be a 1 or 0 for Asian vehicles.

And now if we look at our bar chart, only Asia is highlighted red.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi @Stu_SAS, Thanks for your time assisting on this.

I have the below data structure:

1 – status , directly from SAS table

2 – count , directly from SAS table

3 – % calculated data item – aggregate measure created as below

Sum [_ByGroup_] ('count'n) / Sum [_ForAll_] ('count'n)

Format Percentage applied

4 – % calculated data item as above, but with out percentage format

In your example, both the fields already in sas table. I tried to replicate the example on on sas sample cars table and it worked. In my case (table structure above), I have to use **%** field (**calculated data item – Aggregated measure)** in conjunction with **status**. __Is it possible to use one field that is part of the sas table (…status) and another an aggregate measure (%) together in an expression__ to my requirement to colour bar chart – bar (overdue) and % >0.003.

I tried below expressions using calculated item Aggregate measure %–

IF ( Sum [_ByGroup_] ((

IF ( UpCase('Status'n) = 'OVERDUE' )

RETURN '%'n

ELSE . )) > 0.001 )

RETURN 1

ELSE 0

(IF ('STATUS'n ='Overdue') return ((sum [_ByGroup_] ('%_num'n)) ELSE .) >0.002 )

return 1

else .

Thanks,

RP

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. **Registration is now open through August 30th**. Visit the SAS Hackathon homepage.

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.