Splunk Search

problem with using of CASE results

iKate
Builder

Hi everyone!

Could you please tell me why my search doesn't work.
It has variable click.value $offer_var$ that can be one of the several offer names. Each offer has distinct value of times that a user can exploit it. I need to figue out how many users have reached the maximum value.

source="my_source", service_id="my_service_id" tx_status_id=COMPLETED | fillnull value=none offer_uid | where offer_uid=$offer_var$ | eval max_usage=case(offer_uid == "free_winter", 2, offer_uid == "free_summer", 15, offer_uid == "free_spring", 10) | stats count as usage by user_uid | stats count(eval(usage = max_usage)) as used_offer_completely

For testing purposes I put the name of one of the offers instead of $offer_var$.
Search shows 0 for used_offer_completely but the real result should be other.

Tags (3)
0 Karma
1 Solution

iKate
Builder

I've stumbeled upon my old question and realized that I should change the query as follows:

source="my_source", service_id="my_service_id" tx_status_id=COMPLETED | fillnull value=none offer_uid | where offer_uid=$offer_var$ | eval max_usage=case(offer_uid == "free_winter", 2, offer_uid == "free_summer", 15, offer_uid == "free_spring", 10) | eventstats count as usage by user_uid | stats count(eval(usage = "max_usage")) as used_offer_completely

View solution in original post

0 Karma

iKate
Builder

I've stumbeled upon my old question and realized that I should change the query as follows:

source="my_source", service_id="my_service_id" tx_status_id=COMPLETED | fillnull value=none offer_uid | where offer_uid=$offer_var$ | eval max_usage=case(offer_uid == "free_winter", 2, offer_uid == "free_summer", 15, offer_uid == "free_spring", 10) | eventstats count as usage by user_uid | stats count(eval(usage = "max_usage")) as used_offer_completely

0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...