Dividing two SUM equations does not yield expected result

I'm trying to create a column that divides by "On Hand Weight" by a "Daily Sales Average" to give an estimated amount of days of inventory available.

The "On Hand Weight" is a combination of weight at one facility + the weight at the farm level (decided by a variable entry). This is my current attempt though it seems to be multiplying the variable amount in "Farm Weight" to create a much larger sum than should be.

SUM(On Hand Weight)+Farm Weight / SUM(Daily Sales Average)

Best Answer

  • Sean_Tully
    Sean_Tully Contributor
    Answer ✓

    Sorry, I may have misunderstood the request at first. I think this might work? It sums the on hand weight, and adds the farm weight variable once to that sum. It seemed to work in some mock data I threw together, but let me know if I got it wrong again :)

    (SUM(On Hand Weight)+min(Farm Weight)) / SUM(Daily Sales Average)

Answers

  • Sean_Tully
    Sean_Tully Contributor

    Maybe try wrapping farm weight into the first sum:

    SUM(On Hand Weight+Farm Weight) / SUM(Daily Sales Average)

  • I've tried that. The "Farm Weight" is one single amount assigned through a variable controller where as the "On Hand Weight" is a sum of multiple rows. I believe when I wrap it this way it tries to assign portions of the "Farm Weight" to each row of "On Hand Weight" which results in a number in the millions when it should actually be something in the 10s of thousands.

    I may need to do a further sum/grouping in the ETL instead of trying to accomplish this sum in the analyzer.

  • @Sean_Tully It's definitely something to do with the Variable Farm Weight. Nothing I do recognizes it as a single amount that i'm adding to a "sum". It just keeps trying to create more instances of the variable against the rows of the "On Hand Weight".

  • Jones01
    Jones01 Contributor

    @ChrisGaffan

    can you provide a small sample of the data please?

  • Sean_Tully
    Sean_Tully Contributor
    Answer ✓

    Sorry, I may have misunderstood the request at first. I think this might work? It sums the on hand weight, and adds the farm weight variable once to that sum. It seemed to work in some mock data I threw together, but let me know if I got it wrong again :)

    (SUM(On Hand Weight)+min(Farm Weight)) / SUM(Daily Sales Average)

  • @Sean_Tully That did it. Thank You