Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

MVP
MVP

Re: How can we create a new field based on the values of some other fields??

Ya this seems like a formatting issue then. If that is fixed, the above script will give you the results you are looking for. Can you fix the format in the database itself?

Best,

S

MVP
MVP

Re: How can we create a new field based on the values of some other fields??

For handling the negative value issue, I would use the fabs function. Use the below script:

Table:

LOAD * INLINE [

    Product 1 Sales, Product 2 Sales, Product 3 Sales, Product 4 Sales

    -1001, 0, 0, 0

    0, 456, 0, 0

    0, 0, 123, 0

    0, 0, 0, 345

];

Table2:

LOAD *,

  If(Rangemax(fabs([Product 1 Sales]), fabs([Product 2 Sales]), fabs([Product 3 Sales]), fabs([Product 4 Sales])) = RangeMax(fabs([Product 1 Sales])), 'Good',

  If(Rangemax(fabs([Product 1 Sales]), fabs([Product 2 Sales]), fabs([Product 3 Sales]), fabs([Product 4 Sales])) = RangeMax(fabs([Product 2 Sales])), 'Bad',

  If(Rangemax(fabs([Product 1 Sales]), fabs([Product 2 Sales]), fabs([Product 3 Sales]), fabs([Product 4 Sales])) = RangeMax(fabs([Product 3 Sales])), 'Average',

  If(Rangemax(fabs([Product 1 Sales]), fabs([Product 2 Sales]), fabs([Product 3 Sales]), fabs([Product 4 Sales])) = RangeMax(fabs([Product 4 Sales])), 'Better')))) as Type

Resident Table;

DROP Table Table;

Best,

S

Highlighted
Not applicable

Re: How can we create a new field based on the values of some other fields??

looks like its giving me the desired results!!!!

Thanks a ton!!!!

MVP
MVP

Re: How can we create a new field based on the values of some other fields??

Not a problem. Hope you have a good one.

Best,

S

timanshu
Contributor III

Re: How can we create a new field based on the values of some other fields??

Can You Attach excel/qvw/screenshot of original data To give more clear picture of issue??