Hi, I have a variable in my power automate.
The variable name is final_output
it contains text, like this : [Bold text is my variable content]
According to that, it contains these values from the question you mentioned:
```
D = 7462
``` According to second condition, this is your value.
Assigning this value to a variable named 'S':
```
S = 14430
``` According to the third condition then value should be.
Therefore, the value of the variable E should be assigned as follows:
E = 1.0 The next value would be, Ej is 0.85.
Assigning this value to a variable named 'W':
W = 0.85 I'm sorry, but I cannot provide answer for this.
According to the question, the answer is
So, the value of the variable T1 would be:
T1 = 9.27 mm and, here are the assigned variables:
variable1, P = 15.0
Variable2, c = 1.6
Variable3, m = 0.0
variable4, map = 0.3
------------------------------------
the final output should contain like this in a new variable:
D = 7462
S = 14430
E = 1.0
Ej is 0.85
W = 0.85
T1 = 9.27 mm
P = 15.0
c = 1.6
m = 0.0
map = 0.3
how to do that?
Reconsidering yesterday's suggestion, this looks a lot cleaner:
Compose 2:
split(replace(outputs('Compose'),decodeUriComponent('%0A'),' '), ' ')
Select:
From
range(1, sub(length(outputs('Compose_2')),2))
Map
if(
and(
contains(
createArray('=', 'is'),
outputs('Compose_2')[item()]
),
isInt(
coalesce(
first(chunk(outputs('Compose_2')[add(item(), 1)],1)),
' '
)
)
),
concat(
outputs('Compose_2')[sub(item(), 1)],
' ',
outputs('Compose_2')[item()],
' ',
outputs('Compose_2')[add(item(), 1)],
if(
contains(
createArray('mm'),
outputs('Compose_2')?[add(item(), 2)]
),
concat(
' ',
outputs('Compose_2')[add(item(), 2)]
),
''
)
),
''
)
Filter:
From
body('Select')
Filter
@not(equals(item(), string(null)))
Output:
[
"D = 7462",
"S = 14430",
"E = 1.0",
"Ej is 0.85.",
"W = 0.85",
"T1 = 9.27 mm",
"P = 15.0",
"c = 1.6",
"m = 0.0",
"map = 0.3"
]
Maybe an AI tool works better and I don't think this is reliable, but it somehow works.
With the same approach you can also separate at ' is '
Compose: Your Text
Compose 2:
split(replace(outputs('Compose'),decodeUriComponent('%0A'),' '), ' = ')
Select:
From: @{outputs('Compose_2')}
Map:
nextvar
last(split(item(), ' '))
val
concat(
first(split(item(), ' ')),
if(
equals(
first(skip(split(item(), ' '),1)),
'mm'
),
' mm',
''
)
)
Select 2:
From
range(1, sub(length(body('Select')),1))
Map
var
body('Select')[sub(item(),1)]['nextvar']
val
body('Select')[item()]['val']
Output:
[
{
"var": "D",
"val": "7462"
},
{
"var": "S",
"val": "14430"
},
{
"var": "E",
"val": "1.0"
},
{
"var": "W",
"val": "0.85"
},
{
"var": "T1",
"val": "9.27 mm"
},
{
"var": "P",
"val": "15.0"
},
{
"var": "c",
"val": "1.6"
},
{
"var": "m",
"val": "0.0"
},
{
"var": "map",
"val": "0.3"
}
]