Advent of Code is now back for a limited time only! Complete as many challenges as you can to earn those badges you may have missed in December. Learn more about how to participate here!
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Multi-Field Formula: tried to apply string operator to numeric value (Contain)

MostafaBouzari
8 - Asteroid

Hi everyone,

I want to change A/P column based on a condition.

my condition is 

 

 

IF ToNumber([Saldo])<0 && Contains(ToString([A / P Allocation]), 'Aktiv') THEN 'Passiv1'  ELSEIf   ToNumber([Saldo])>0 && Contains(ToString([A / P Allocation]), 'P&L' OR 'Passiv') THEN  
'Aktiv2'  
else
[A / P Allocation] ENDIF

 

 

Note that i have added ToNumber and ToString after that i got the Error but that didn't solved my problem.

But Multifield Tool is giving me a an error:

 

 

Multi-Field Formula (3)	Formula: tried to apply string operator to numeric value(Contains)

 

Which i can not understand what that means.

Also this is my data

AccountDateDescriptionSaldoU/AChart of AccountsHGB GKVA / P Allocation
75982018-12ttt-10unadjustedunalloctedxxxP&L
87642016-12uuu56.14unadjustedxxxxxxP&L
34672017-12zzz148.34unadjustedxxxxxxP&L
86312018-12xxx281.4unadjustedxxxxxxP&L
2112016-12eeee-3800unadjustedrrB.2.1Aktiv
223452017-12eeee-9450unadjustedrrB.2.1Aktiv
645672018-12eeee-9450unadjustedrrB.2.1Aktiv
4532016-12eeee28306unadjustedrrHPassiv

and i have Selected A/P Allocation in the configuration 

 

What am i missing?

 

Regards

3 REPLIES 3
patrick_digan
17 - Castor
17 - Castor

@MostafaBouzari I don't think you need tostring around A/P, and you can't put an or inside contains. I think it would be:

 

 

IF ToNumber([Saldo])<0 && Contains([A / P Allocation], 'Aktiv') THEN 'Passiv1'  ELSEIf   ToNumber([Saldo])>0 && (Contains([A / P Allocation], 'P&L')  OR Contains([A / P Allocation],'Passiv')) THEN  
'Aktiv2'  
else
[A / P Allocation] ENDIF

 

 

As for Saldo, you only need the tonumber function if saldo is a string variable. You can click on the line between tools to confirm the data type. 

 

EDIT: perhaps I'm missing something, but I don't see any reason to use a multi-field formula for your formula. A normal formula tool should work fine. 

MostafaBouzari
8 - Asteroid

i still get the same error

 

alter.PNG

RolandSchubert
16 - Nebula
16 - Nebula

Hi @MostafaBouzari,

 

I wonder, why you are using a Multi-Field Formula. It seems, you want to assign a new value to the column 'A/P Allocation', so a Formula tool should do the job.

In additoon, the field [A / P Allocation] seems to be a string field, the formula could be:

 

IF ToNumber([Saldo]) < 0 AND Contains([A / P Allocation], 'Aktiv') THEN
'Passiv1'
ELSEIf ToNumber([Saldo])>0 AND (Contains([A / P Allocation], 'P&L' ) OR Contains([A / P Allocation], 'Passiv')) THEN
'Aktiv2'
ELSE
[A / P Allocation]
ENDIF

 

Hope this is helpful.

 

Best,

 

Roland

Labels
Top Solution Authors