Search code examples
export-to-csvazure-logic-apps

How to operate on value in Create CSV step of Logic App?


I need to multiply the max_pay__c item in a record by 0.95 before including it in CSV table. What is the best method for that?

enter image description here

I've tried using ...

@mul(item()?['max_pay_c'],0.95) 

... function, but that seems to use NULL for item()?['max_pay_c']

These are the first few records from "Get records" :

{
  "body": {
    "value": [
      {
        "@odata.etag": "",
        "ItemInternalId": "ccbce48a-cf62-4e3f-bd56-94b90764e1ca",
        "Delivery_ScheduledEndDateTime__c": "2023-01-30T18:00:00Z",
        "Delivery_ScheduledStartDateTime__c": "2023-01-30T14:00:00Z",
        "Pickup_ScheduledEndDateTime__c": "2023-01-17T21:00:00Z",
        "Pickup_ScheduledStartDateTime__c": "2023-01-17T13:00:00Z",
        "Weight__c": 30250,
        "dest_city__c": "WARMINSTER",
        "dest_state__c": "PA",
        "dest_zip__c": "18974",
        "max_pay__c": 850,
        "orig_zip__c": "23320",
        "origin_city__c": "CHESAPEAKE",
        "origin_state__c": "VA"
      },
      {
        "@odata.etag": "",
        "ItemInternalId": "3eac0b25-bde8-4185-89c0-0b15827d13ff",
        "Delivery_ScheduledEndDateTime__c": "2023-01-20T13:30:00Z",
        "Delivery_ScheduledStartDateTime__c": "2023-01-20T13:30:00Z",
        "Pickup_ScheduledEndDateTime__c": "2023-01-16T22:00:00Z",
        "Pickup_ScheduledStartDateTime__c": "2023-01-16T14:00:00Z",
        "Weight__c": 38845,
        "dest_city__c": "MILWAUKIE",
        "dest_state__c": "OR",
        "dest_zip__c": "97222",
        "max_pay__c": 6316.132222873688,
        "orig_zip__c": "78045",
        "origin_city__c": "LAREDO",
        "origin_state__c": "TX"
      },
      {
        "@odata.etag": "",
        "ItemInternalId": "e6f249a6-dd8f-4e4f-8de7-d1e37d611896",
        "Delivery_ScheduledEndDateTime__c": "2023-01-18T18:00:00Z",
        "Delivery_ScheduledStartDateTime__c": "2023-01-18T14:00:00Z",
        "Pickup_ScheduledEndDateTime__c": "2023-01-17T21:00:00Z",
        "Pickup_ScheduledStartDateTime__c": "2023-01-17T13:00:00Z",
        "Weight__c": 30250,
        "dest_city__c": "WARMINSTER",
        "dest_state__c": "PA",
        "dest_zip__c": "18974",
        "max_pay__c": 900,
        "orig_zip__c": "23320",
        "origin_city__c": "CHESAPEAKE",
        "origin_state__c": "VA"
      },
      {
        "@odata.etag": "",
        "ItemInternalId": "a2593a84-a224-4e78-bdf0-184d4ad112bd",
        "Delivery_ScheduledEndDateTime__c": "2023-01-23T13:30:00Z",
        "Delivery_ScheduledStartDateTime__c": "2023-01-23T13:30:00Z",
        "Pickup_ScheduledEndDateTime__c": "2023-01-18T17:00:00Z",
        "Pickup_ScheduledStartDateTime__c": "2023-01-18T17:00:00Z",
        "Weight__c": 42640,
        "dest_city__c": "MILWAUKIE",
        "dest_state__c": "OR",
        "dest_zip__c": "97222",
        "max_pay__c": 5700,
        "orig_zip__c": "08837",
        "origin_city__c": "EDISON",
        "origin_state__c": "NJ"
      },
      {
        "@odata.etag": "",
        "ItemInternalId": "be8ba5c3-ea31-4da5-9369-17055c3776c2",
        "Delivery_ScheduledEndDateTime__c": "2023-01-18T16:00:00Z",
        "Delivery_ScheduledStartDateTime__c": "2023-01-18T16:00:00Z",
        "Pickup_ScheduledEndDateTime__c": "2023-01-16T18:00:00Z",
        "Pickup_ScheduledStartDateTime__c": "2023-01-16T18:00:00Z",
        "Weight__c": 24624,
        "dest_city__c": "FOREST PARK",
        "dest_state__c": "GA",
        "dest_zip__c": "30297",
        "max_pay__c": 2700,
        "orig_zip__c": "78045",
        "origin_city__c": "LAREDO",
        "origin_state__c": "TX"
      },
      {
        "@odata.etag": "",
        "ItemInternalId": "05b6dfb9-f502-4de5-b6b4-827c18706c33",
        "Delivery_ScheduledEndDateTime__c": "2023-01-13T16:00:00Z",
        "Delivery_ScheduledStartDateTime__c": "2023-01-13T16:00:00Z",
        "Pickup_ScheduledEndDateTime__c": "2023-01-12T19:00:00Z",
        "Pickup_ScheduledStartDateTime__c": "2023-01-12T19:00:00Z",
        "Weight__c": 35998,
        "dest_city__c": "PHILADELPHIA",
        "dest_state__c": "PA",
        "dest_zip__c": "19154",
        "max_pay__c": 655.6680024414063,
        "orig_zip__c": "21075",
        "origin_city__c": "ELKRIDGE",
        "origin_state__c": "MD"
      }
    ]
  }
}

Solution

  • I can see that the variable that you are trying to pass is actually max_pay__c but you are using max_pay_c for your expression. After making that change from my end, this was working fine. Below is the expression I'm using.

    mul(items('For_each')?['max_pay__c'],0.95)
    

    enter image description here

    Results:

    enter image description here