3 Replies Latest reply: Sep 6, 2017 8:54 PM by Sunny Talwar RSS

    Calculated Field in If Match Statement

    Steph Bass

      I have an App that is linked to our GL and I am trying to create a field that rolls these GLs up into the line totals people are used to seeing.

       

      For example, say GL account numbers 900000 and 910000 are both included in our Gasoline Sales P&L Line, and 905000 and 915000 are both included in our Diesel Sales P&L Line, I have rolled these up so that they are included in a new field I named P&L Line. See below:

       

      If(Match([AccountNum],'900000','910000'),'01. Gas Gallons',

          If(Match([AccountNum],'905000','915000'),'04. Diesel Gallons','Other')) AS 'P&L Line'


      These are all working as expected, but my issue is that I also want to have a third 'P&L Line' that totals these two as 'Total Gallons' and haven't figured out how I can have all three.

       

      TIA!

        • Re: Calculated Field in If Match Statement
          Sunny Talwar

          You will have to use Where statement with Concatenation....

           

          Fact:

          LOAD AccountNum,

               OtherFields

          FROM ....;

           

          LinkTable:

          LOAD AccountNum,

               If(Match([AccountNum],'900000','910000'),'01. Gas Gallons',

                    If(Match([AccountNum],'905000','915000'),'04. Diesel Gallons','Other')) AS 'P&L Line'

          Resident Fact;


          Concatenate (LinkTable)

          LOAD AccountNum,

               'Total Gallons' as 'P&L Line'

          Resident Fact

          Where Match([AccountNum],'900000','910000', '905000','915000')

            • Re: Calculated Field in If Match Statement
              Steph Bass

              Thank you Sunny!

               

              This did work to give me Total Gallons, but now that is all I have, rather than having all three: Total Gallons, Gas Gallons, and Diesel Gallons.

               

              Any suggestions on how to add Total Gallons as a 'P&L Line' in addition to Gas Gallons & Diesel Gallons?

                • Re: Calculated Field in If Match Statement
                  Sunny Talwar

                  Did you have this in your script?

                   

                  Fact:

                  LOAD AccountNum,

                      OtherFields

                  FROM ....;

                   

                  LinkTable:

                  LOAD AccountNum,

                      If(Match([AccountNum],'900000','910000'),'01. Gas Gallons',

                            If(Match([AccountNum],'905000','915000'),'04. Diesel Gallons','Other')) AS 'P&L Line'

                  Resident Fact;


                  Concatenate (LinkTable)

                  LOAD AccountNum,

                      'Total Gallons' as 'P&L Line'

                  Resident Fact

                  Where Match([AccountNum],'900000','910000', '905000','915000')