Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello all,
I have already imported those fields as an example:
Field_a |
9 |
8 |
4 |
2 |
Year |
1 |
2 |
3 |
4 |
5 |
6 |
My ouput should look like:
Operation: If value (Field_a) >5 then value(Field_b)=value(Field_a)*2*Year else value(Field_b)=value(Field_a)*Year/2
NB: These operations should be performed in the script and not as a chart expression.
Year/Field _b | ||||
1 | 3 | 4 | 5 | 6 |
2 | 6 | 8 | 10 | 12 |
3 | ... | |||
4 | ... | |||
5 | ... | |||
6 | ... |
Any help please?
Thanks in advance
Hi
First attempt would be like this:
Fields:
load * inline [
Field_a
9
8
4
2
];
join(Fields)
Years:
load * inline [
Year
1
2
3
4
5
6
];
NoConcatenate
Result:
load Field_a, Year, if(Field_a > 5, Field_a*2*Year, Field_a*Year/2) as Field_b Resident Fields;
drop table Fields;
This code will give you output like this:
But one thing is weird. The output format suggest that you want to have many columns named Field_b - that's impossible.
Hi,
thank you for your prompt reply.
It works but I have problem with non integers. Multiplication cannot be performed with non integers.
What could be the solution when Field_a would look like:
Field_a
9.81
8.8
4.8114
2.815
Thanks in advance.
Hi, what is your source of thouse digits?
I've changed values in my inline load and it works correctly.
The same with non integers:
Fields:
load * inline [
Field_a
9.8
8.8
4.8
2.8
];
join(Fields)
Years:
load * inline [
Year
1
2
3
4
5
6
];
NoConcatenate
Result:
load Field_a, Year, if(Field_a > 5, Field_a*2*Year, Field_a*Year/2) as Field_b Resident Fields;
drop table Fields;
With the following output:
Hmm that's weird. Same loadScript on my qlik gives different results.
When you check the model with ctrl+t what qlikview says about type of Field_a ?
I'm using polish language in qlik so presentation can be different but the $numeric info should be the same 😉
Maybe try to force this field with num#(Field_a) as Field_a in load.
ascii and text and it didn't work with num# as well.
And what is the field type of field_a in model viewer?