Basic Math Operations using
Dataweave
Transform
• Sum
• %dw 1.0 %output application/xml
---
plus : 2 + 2.5
output
Minus
• %dw 1.0
• %output application/xml
• ---
• minus : 2.5 - 2
Multiply
• %dw 1.0
• %output application/xml
• ---
• multiply : 2.5 * 2
Transform and output
Division
• %dw 1.0
• %output application/xml
• ---
• division : 10 / 2
Transform and output
Max
• (':array')/(':object') ⇒ ':number'
• Returns the highest number in an array or object.
• %dw 1.0
• %output application/json
• ---
• {
• a: max [1..1000],
• b: max [1, 2, 3],
• d: max [1.5, 2.5, 3.5]
• }
Transform and output
Transform and output
Min
• %dw 1.0
• %output application/json
• ---
• {
• a: min [1..1000],
• b: min [1, 2, 3],
• d: min [1.5, 2.5, 3.5]
• }
Transform and output
Round
• (':number') ⇒ ':number'
Rounds the value of a number to the nearest integer
• %dw 1.0 %output application/json
• ---
• {
• a: round 1.2,
• b: round 4.6,
• c: round 3.5
• }
Transform and output
Sqrt
• %dw 1.0 %output application/json
• ---
• {
• a: sqrt 4,
• b: sqrt 25,
• c: sqrt 100
• }
Transform and output

Basic math operations using dataweave