Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Get first fieldname name with a value condition

Hi,

I want to have a new column on a table that gives me the first column that has a specific value.

So,

I have this

            

Header 1Header 2Header 3Header 4Header 5
NameMonth1Month2Month3Month4
A0033
B0401
C0321
D1001

I would like to add a column with the name of the first column that has a value higher than 0.

Header 1Header 2Header 3Header 4Header 5Header 6
NameMonth1Month2Month3Month4FirstMonthSales
A0033Month3
B0401Month2
C0321Month2
D1001Month1

So, the FirstMonthSales column should have the first month that has a value higher than 0.

Thanks,

Dani

2 Replies
salto
Specialist II
Specialist II

Hello Dani,

First load the table data into a resident table:

ResidentTable:

Load

Name,

Month1,

Month2,

Month3,

Month4

From Data.xls(biff, embedded laels, table is Sheet1$)

Then reload the table data and put an IF to check the first month with sales:

Data:

Load

     *,

     if(Month1>0,Month1,if(Month2>0,Month2,If(Month3>0,Month3,Month4))) as FirstMonthSales

resident ResidentTable;

drop table ResidentTable;

Hope this helps!

pgrenier
Partner - Creator III
Partner - Creator III

Hello Dani,

I guess it depends on what you are ready to change in order to obtain your result. Please find an example file based on a CrossTable approach of your result set. In that file, you shall see that using a Pivot Table will not permit to see the desired result, but if you opt to do a little hard coding, you may get your desired presentation with a Straight Table.

Otherwise, by joining objects within a container, you may also simulate the result using both types of objects.

Cheers,

Philippe