Charting

Charting

Beast mode adding two columns with conditions

Hello Dojo,

I'm having trouble adding two columns with in a conditional case. The following works fine:

  1. SUM(`paid_total`) + SUM(`booked_total`)


But then when I try to add any sort of condition, it fails: "An issue has occurred during processing. We are unable to complete the request at this time."

  1. case
  2. when `payment_number` >= 1
  3. then SUM(`paid_total`) + SUM(`booked_total`)
  4. else 0
  5. end

I've tried wrapping the whole statement in a SUM as it suggests to do in the docs, but that also doesn't work.

  1. SUM(
  2. case
  3. when `payment_number` >= 1
  4. then SUM(`paid_total`) + SUM(`booked_total`)
  5. else 0
  6. end
  7. )
  8.  

Any thoughts here? I've exhausted every other help page on this topic I could find in the Dojo, to no avail.

Answers

  • Contributor
    1. CASE WHEN `payment_number` > 0 THEN SUM(SUM(`paid_total`) + SUM(`booked_total`)) ELSE 0 END


  • @domo_sensei2

    Domo cannot apply a CASE statement AFTER the aggregate.

    If you need to apply a CASE statement on the aggregate, then you have to pre-aggreagte the data in ETL or a Dataset View.

    (you could then JOIN the preaggregated data back onto the transactions to retain the granular detail.

    https://www.youtube.com/watch?v=Esnu1PSxRjM&t=633s

    Jae Wilson
    Check out my 🎥 Domo Training YouTube Channel 👨‍💻

    **Say "Thanks" by clicking the ❤️ in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In