BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sseanhennessyy
Obsidian | Level 7

I'm wondering if there is anyway to do a calculation by specific groups within the same column of data.

 

If I have the following data set, I want to be able to sum the Count column by Status then divide the sum of sold status count by the sum of proposed status count. Is this possible is VA?

 

Status      Count

Proposed      1

Sold              1

Proposed      1

Sold              1

Proposed      1

Proposed      1

 

I know I can manipulate the data prior to bring it into VA and columns for 'Sold Count' and 'Proposed Count' and would be able to do the calculation that way, just curious if there is another way.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
FredrikE
Rhodochrosite | Level 12

I think you need to create two calculated items one for each status and then create a calculation between them

Var 1: if status = 'sold' then count else . | Aggregation = count.

Var 2: if status = 'proposed' then count else . | Aggregation = count.

 

Var 3: var 1 / var 2

 

I have not seen any example (yet) on how to do it using just one column 🙂

//Fredrik

View solution in original post

2 REPLIES 2
FredrikE
Rhodochrosite | Level 12

I think you need to create two calculated items one for each status and then create a calculation between them

Var 1: if status = 'sold' then count else . | Aggregation = count.

Var 2: if status = 'proposed' then count else . | Aggregation = count.

 

Var 3: var 1 / var 2

 

I have not seen any example (yet) on how to do it using just one column 🙂

//Fredrik

sseanhennessyy
Obsidian | Level 7

Ah yes, that works. Didn't think to do the counts in VA. Perfect!

 

Just for reference, here is the actual text that is working for me:

 

IF ( 'STATUS'n In ('SOLD') )
RETURN 'COUNT'n
ELSE 0

Ready to join fellow brilliant minds for the SAS Hackathon?

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

Register today!
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.

Discussion stats
  • 2 replies
  • 964 views
  • 0 likes
  • 2 in conversation