1 2 Previous Next 15 Replies Latest reply on Sep 19, 2017 6:45 AM by Andrea Benvenuti

    Need help with calculation

    Andrea Benvenuti

      Hello guys hopefully someone can help me with this calculation, I will try to be as clear as possible.

       

      Right now I am trying to make a sum of a calculation  but before we dive there this is the situation, I have this fields:

      ID_SOSPENSIONE

      ID_ACCESSO

      ID_PRESA_CARIC

       

      I am calculating (trying to ..)for each  ID_PRESA_CARIC the sum of the days of Sospensione, keep in mind each ID_PRESA_CARIC might have 1 or more ID_SOSPENSIONE.

       

      That said i am calculating each SOSPENSIONE by making the difference betweeen the access min and max for each id ID_SOSPENSIONE, so i have 3 calculated field

      CALCOLO_GIORNI_SOSP1

      DATEDIFF('day', IFNULL([DATA_MIN_ACCESSO], TODAY() ), IFNULL([DATA_MAX_ACCESSO], TODAY() ))

       

      CALCOLO_GIORNI_SOSP2

      IF

      DATEDIFF('day', IFNULL(ATTR([DATA_FINE_SOSPENSIONE]), TODAY() ), [DATA_MAX_ACCESSO]) <= 0 THEN 0

      ELSEIF DATEDIFF('day', IFNULL(ATTR([DATA_FINE_SOSPENSIONE]), TODAY() ), [DATA_MIN_ACCESSO])>= 0 THEN 0

      ELSE

      DATEDIFF('day', IFNULL(ATTR([DATA_FINE_SOSPENSIONE]), TODAY() ), [DATA_MAX_ACCESSO])

      END

       

      CALCOLO_GIORNI_SOSP3

      IF

      DATEDIFF('day', [DATA_MIN_ACCESSO], ATTR([DATA_INIZIO_SOSPENSIONE])) <= 0 THEN 0

      ELSEIF DATEDIFF('day', [DATA_MAX_ACCESSO], ATTR([DATA_INIZIO_SOSPENSIONE])) >= 0 THEN 0

      ELSE DATEDIFF('day', [DATA_MIN_ACCESSO], ATTR([DATA_INIZIO_SOSPENSIONE]))

      END

       

      At the end the total for each sospensione is correct (if i put in the row field ) fopr example i see id 1 as 3 days and id 2 as 4 days, but I cannot get the sum to work, if i remove the id_sospensione from the row i get an empty box instead of the sum of both value (in this case should be 7).

       

      Hopefully it is clear enought!!

       

      Thank you for any help!!!!!!

        1 2 Previous Next