Beast mode using AND and OR

Trying to run sales data to determine how many reps have open opportunities within one of the 5 products as well as of those opportunities which ones have status of closed. I am using this beast mode to find whenever the opportunity status doesn't =  a status thats closed and the item is PBCS then put a 1 so I can sum/count the nuymber

SUM((CASE when ((`Opportunity Status` <> 'closed won' or `Opportunity Status` <> 'lost') and `Item` = 'ARM') then 1 else 0 end)) 

 

Issue is, it is still pulling opportunities with lost and closed won statuses. I have this same beast mode for all 5 items and they are all set as columns which I need to show up with their own distinct values

 

Secondly, I want to reverse it and find when the opportunties are marked closed won statuses to count/sum the number they have closed

 

ultimately need a card that shows total open opps per item by rep vs number of closed by that item

 

thanks!!

Best Answers

  • AS
    AS Coach
    Answer ✓

    Are the values correct that we're filtering on?  Like, are the capitalizations correct?  Those are pretty specific strings to match.

    Aaron
    MajorDomo @ Merit Medical

    **Say "Thanks" by clicking the heart in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • [Deleted User]
    Answer ✓

    @user00617

     

    Did the latest replies help you get additional clarity?

    Thanks!
    Dani

Answers

  • AS
    AS Coach

    How about something like this:

     

    SUM(

    CASE

    WHEN `Item` = 'ARM' AND `Opportunity Status` NOT IN ( 'closed won','lost')

    THEN 1

    ELSE 0

    END)

     

    And

     

    SUM(

    CASE

    WHEN `Item` = 'ARM' AND `Opportunity Status` =  'closed won'

    THEN 1

    ELSE 0

    END)

    Aaron
    MajorDomo @ Merit Medical

    **Say "Thanks" by clicking the heart in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • Hmmm still counted all opps no matter what the status. Looks like it is only reading the 'Item' = 'ARM'  and is pulling all opps for that.

  • AS
    AS Coach
    Answer ✓

    Are the values correct that we're filtering on?  Like, are the capitalizations correct?  Those are pretty specific strings to match.

    Aaron
    MajorDomo @ Merit Medical

    **Say "Thanks" by clicking the heart in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • Hi Aaron,

     

    Circling back to this, do you know how I can make that a filter? I am showing all of the opportunities now per rep but I only want to see when they have 0 opportunities?

     

    Thnaks for the help!

  • You cannot use an aggregate function as a filter. You could sort in ascending order and then the reps with 0 opportunities should be listed first.


    “There is a superhero in all of us, we just need the courage to put on the cape.” -Superman
  • AS
    AS Coach

    @ST_-Superman-_ is correct.  Filtering on aggregations is one of the top-requested features, I would estimate.

    Aaron
    MajorDomo @ Merit Medical

    **Say "Thanks" by clicking the heart in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • Thanks for the help.

     

    Are there any work arounds, beastmodes, or any other way that you can think of that would allow me just to show all the 0s (without sorting).

     

    Thanks!

  • AS
    AS Coach

    Sorry, nothing that jumps out in my mind right now.

    Aaron
    MajorDomo @ Merit Medical

    **Say "Thanks" by clicking the heart in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • I'm wondering if a Windowed function would work for this:

     

    SUM(

    CASE

    WHEN `Item` = 'ARM' AND `Opportunity Status` NOT IN ( 'closed won','lost')

    THEN 1

    ELSE 0

    END)

    OVER

    (PARTITION BY `Employee Identifier`)

     

    You would need to first have the data sorted by the employee identifier field for this to work.  But this would provide a field the I think you could filter on.  Haven't tested this though.  If you have trouble, please provide a sample of your data and I'll see if I can get something working


    “There is a superhero in all of us, we just need the courage to put on the cape.” -Superman
  • AS
    AS Coach

    That very well could be.  Window functions aren't supported that I'm aware so I don't think there's any documentation to help out yet.  It's all trial and error, hope and dissapointment for now. Lol.  

    Aaron
    MajorDomo @ Merit Medical

    **Say "Thanks" by clicking the heart in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • 1.png

     

    They are a little tricky to get working, but window functions are available in beast mode.


    “There is a superhero in all of us, we just need the courage to put on the cape.” -Superman
  • To quote Joey from Friends, it may be a "moo" point anyway as I could not filter on this field.  


    “There is a superhero in all of us, we just need the courage to put on the cape.” -Superman
  • [Deleted User]
    Answer ✓

    @user00617

     

    Did the latest replies help you get additional clarity?

    Thanks!
    Dani

  • Our domo instance doesnt allow Window functions in Beast mode. Is this something that needs to be turned on the admin side?