<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: division of two fields using jolt spec in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/division-of-two-fields-using-jolt-spec/m-p/370574#M240762</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp; for the quick help. division got worked&lt;/P&gt;&lt;P&gt;but after this division the value coming with 2 decimal values , where as i needed 8 decimal points after the dot. so far that i've used below logic in the same spec. but its giving empty value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"ScontoMaggiorazione": {&lt;BR /&gt;"*": {&lt;BR /&gt;"first_Importo": "=divide(@(1,Importo),@(3,Quantita))",&lt;BR /&gt;"array_importo": "=split('.',@(1,first_Importo))",&lt;BR /&gt;"pad_importo": "=rightPad(@(1,array_importo[1]), 8, '0')",&lt;BR /&gt;"Importo": "=concat(@(1,array_importo[0]),'.',@(1,pad_importo))"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any idea on this too?&lt;/P&gt;</description>
    <pubDate>Thu, 11 May 2023 19:15:00 GMT</pubDate>
    <dc:creator>PradNiFi1236</dc:creator>
    <dc:date>2023-05-11T19:15:00Z</dc:date>
    <item>
      <title>division of two fields using jolt spec</title>
      <link>https://community.cloudera.com/t5/Support-Questions/division-of-two-fields-using-jolt-spec/m-p/370572#M240760</link>
      <description>&lt;P&gt;i'm trying to perform Importo= importo/Quantita&amp;nbsp; for each line item value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but unable get the division even though i've used =divide function. Could you please help me&lt;/P&gt;&lt;P&gt;input:&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"FatturaElettronicaBody": {&lt;BR /&gt;"DatiBeniServizi": {&lt;BR /&gt;"DettaglioLinee": [&lt;BR /&gt;{&lt;BR /&gt;"NumeroLinea": 1,&lt;BR /&gt;"Quantita": "3.0",&lt;BR /&gt;"PrezzoUnitario": "311.55000000",&lt;BR /&gt;"AliquotaIVA": "22.00",&lt;BR /&gt;"ScontoMaggiorazione": [&lt;BR /&gt;{&lt;BR /&gt;"Tipo": "SC",&lt;BR /&gt;"Percentuale": "28.00",&lt;BR /&gt;"Importo": "261.69"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"Descrizione": "B66450458 SACCA DA GOLF",&lt;BR /&gt;"PrezzoTotale": "672.96000000"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"NumeroLinea": 2,&lt;BR /&gt;"Quantita": "1.00000000",&lt;BR /&gt;"PrezzoUnitario": "311.55000000",&lt;BR /&gt;"AliquotaIVA": "22.00",&lt;BR /&gt;"ScontoMaggiorazione": [&lt;BR /&gt;{&lt;BR /&gt;"Tipo": "SC",&lt;BR /&gt;"Percentuale": "28.00",&lt;BR /&gt;"Importo": "87.23000000"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"Descrizione": "B66450458 SACCA DA GOLF",&lt;BR /&gt;"PrezzoTotale": "224.32000000"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"NumeroLinea": 3,&lt;BR /&gt;"Quantita": "1.00000000",&lt;BR /&gt;"PrezzoUnitario": "311.55000000",&lt;BR /&gt;"AliquotaIVA": "22.00",&lt;BR /&gt;"ScontoMaggiorazione": [&lt;BR /&gt;{&lt;BR /&gt;"Tipo": "SC",&lt;BR /&gt;"Percentuale": "28.00",&lt;BR /&gt;"Importo": "87.23000000"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"Descrizione": "B66450458 SACCA DA GOLF",&lt;BR /&gt;"PrezzoTotale": "224.32000000"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"NumeroLinea": 4,&lt;BR /&gt;"Quantita": "3.00000000",&lt;BR /&gt;"PrezzoUnitario": "2150.00000000",&lt;BR /&gt;"AliquotaIVA": "22.00",&lt;BR /&gt;"ScontoMaggiorazione": [&lt;BR /&gt;{&lt;BR /&gt;"Tipo": "SC",&lt;BR /&gt;"Percentuale": "16.00",&lt;BR /&gt;"Importo": "1032.00000000"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"Descrizione": "A205330410780 INGRANAGGI E DIFFER. ANT.",&lt;BR /&gt;"PrezzoTotale": "5418.00000000"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"NumeroLinea": 5,&lt;BR /&gt;"Quantita": "7.00000000",&lt;BR /&gt;"PrezzoUnitario": "202.96000000",&lt;BR /&gt;"AliquotaIVA": "22.00",&lt;BR /&gt;"ScontoMaggiorazione": [&lt;BR /&gt;{&lt;BR /&gt;"Tipo": "SC",&lt;BR /&gt;"Percentuale": "19.00",&lt;BR /&gt;"Importo": "269.92000000"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"Descrizione": "A6510108918 COPERCHIO TESTATA CIL.",&lt;BR /&gt;"PrezzoTotale": "1150.80000000"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jolt Spec:&lt;/P&gt;&lt;P&gt;[{&lt;BR /&gt;"operation": "modify-overwrite-beta",&lt;BR /&gt;"spec": {&lt;BR /&gt;"FatturaElettronicaBody": {&lt;BR /&gt;"DatiGenerali": {&lt;BR /&gt;"DatiBeniServizi": {&lt;BR /&gt;"DettaglioLinee": {&lt;BR /&gt;"*": {&lt;BR /&gt;"ScontoMaggiorazione": {&lt;BR /&gt;"*": {&lt;BR /&gt;"Importo": "=divide(@(1,Importo),@(1,Quantita))"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"operation": "shift",&lt;BR /&gt;"spec": {&lt;BR /&gt;"FatturaElettronicaBody": {&lt;BR /&gt;"DatiBeniServizi": {&lt;BR /&gt;"DettaglioLinee": {&lt;BR /&gt;"*": {&lt;BR /&gt;"NumeroLinea": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&amp;amp;1].NumeroLinea",&lt;BR /&gt;"Descrizione": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&amp;amp;1].Descrizione",&lt;BR /&gt;"Quantita": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&amp;amp;1].Quantita",&lt;BR /&gt;"PrezzoUnitario": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&amp;amp;1].PrezzoUnitario",&lt;BR /&gt;"ScontoMaggiorazione": {&lt;BR /&gt;"*": {&lt;BR /&gt;"Importo": "FatturaElettronicaBody.DatiBeniServizi.DettaglioLinee[&amp;amp;3].ScontoMaggiorazione[&amp;amp;3].Importo"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}]&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 18:18:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/division-of-two-fields-using-jolt-spec/m-p/370572#M240760</guid>
      <dc:creator>PradNiFi1236</dc:creator>
      <dc:date>2023-05-11T18:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: division of two fields using jolt spec</title>
      <link>https://community.cloudera.com/t5/Support-Questions/division-of-two-fields-using-jolt-spec/m-p/370573#M240761</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please see the modified spec below. The comments indicate what I had to do to make your modify-overwrite-beta spec works based on the input json. I hope it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[{
  "operation": "modify-overwrite-beta",
  "spec": {
    "FatturaElettronicaBody": {
      // The DatiGenerali level is not found in the input JSON
      // "DatiGenerali": {
      "DatiBeniServizi": {
        "DettaglioLinee": {
          "*": {
            //level3 
            "ScontoMaggiorazione": {
              // level2
              "*": {
                // Quantita is located level 3 and not level 1
                "Importo": "=divide(@(1,Importo),@(3,Quantita))"
              }
            }
          }
        }
      }
      //}
    }
  }
}]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 18:43:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/division-of-two-fields-using-jolt-spec/m-p/370573#M240761</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-05-11T18:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: division of two fields using jolt spec</title>
      <link>https://community.cloudera.com/t5/Support-Questions/division-of-two-fields-using-jolt-spec/m-p/370574#M240762</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp; for the quick help. division got worked&lt;/P&gt;&lt;P&gt;but after this division the value coming with 2 decimal values , where as i needed 8 decimal points after the dot. so far that i've used below logic in the same spec. but its giving empty value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"ScontoMaggiorazione": {&lt;BR /&gt;"*": {&lt;BR /&gt;"first_Importo": "=divide(@(1,Importo),@(3,Quantita))",&lt;BR /&gt;"array_importo": "=split('.',@(1,first_Importo))",&lt;BR /&gt;"pad_importo": "=rightPad(@(1,array_importo[1]), 8, '0')",&lt;BR /&gt;"Importo": "=concat(@(1,array_importo[0]),'.',@(1,pad_importo))"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any idea on this too?&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 19:15:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/division-of-two-fields-using-jolt-spec/m-p/370574#M240762</guid>
      <dc:creator>PradNiFi1236</dc:creator>
      <dc:date>2023-05-11T19:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: division of two fields using jolt spec</title>
      <link>https://community.cloudera.com/t5/Support-Questions/division-of-two-fields-using-jolt-spec/m-p/370580#M240765</link>
      <description>&lt;P&gt;I think you had it right but you need to convert the division value into string before applying split on it. Here are the steps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; "decImporto": "=divide(@(1,Importo),@(3,Quantita))",
 "strImporto": "=toString(@(1,decImporto))",
 "array_importo": "=split('[.]',@(1,strImporto))",
 "pad_importo": "=rightPad(@(1,array_importo[1]), 8, '0')",
 "Importo": "=concat(@(1,array_importo[0]),'.',@(1,pad_importo))"
      &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 22:51:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/division-of-two-fields-using-jolt-spec/m-p/370580#M240765</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2023-05-11T22:51:53Z</dc:date>
    </item>
  </channel>
</rss>

