0

I have a dataset with a field as Order Country. It has field values as 'AUS', 'USA', 'GBR', 'IND', 'KEN', etc. Now, is there any way to bucket these values as

bucket 1: 'AUS', 'USA', 'GBR' - Total id count of these three countries
bucket 2: 'USA', 'GBR', 'IND', 'KEN' - Total id count of these Four countries
bucket 3: 'KEN', 'AUS', 'IND' - Total id count of these three countries

Please suggest

2 Answers 2

2

Basically you have 2 options:

  1. Bucket in a dataflow or recipe
  2. Bucket in the dashboard. For that you have to write custom SAQL. In your query insert a line containing "case when" like the following
q = foreach q generate case when orderCountry in ["AUS", "USA", "GBR"]
                            then "Yes"
                            else "No"
                       end as Bucket1,
                       case when orderCountry in ["USA", "GBR", "IND", "KEN"]
                            then "Yes"
                            else "No"
                       end as Bucket2,
                       case when orderCountry in ["KEN", "AUS", "IND"]
                            then "Yes"
                            else "No"
                       end as Bucket3;

Then create subqueries to count

result1 = group q by Bucket1;
result1 = foreach result1 generate Bucket1, count() as countBucket1;

result2 = group q by Bucket2;
result2 = foreach result2 generate Bucket2, count() as countBucket2;

result3 = group q by Bucket3;
result3 = foreach result3 generate Bucket3, count() as countBucket3;

And finally union or cogroup the suqueries back together, depending on what you want to do with these numbers.

Hope that helps!

0
0

This worked for me, however, I am not able to do a chart out of it now that I used the saql. Is that what the subqueries to count =result part is for?

2
  • 1
    Please see the note about "commentary on...other answers" in Why and how are some answers deleted? & be aware that your "answer" will most likely be deleted. Please contribute to SFSE in other ways so that you gain reputation - you only need 15 rep to upvote a question & only 50 to comment under someone else's post. Or you could Follow the Q or A to be notified when it is updated, or possibly ask a new question, and in it link to this Q or its other answer for reference.
    – Moonpie
    Commented May 23, 2022 at 19:46
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review
    – Derek F
    Commented May 23, 2022 at 23:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .