Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If-Function / Simples Question

Dear All,

How i can create an expression to define a Column Title based in a conditional.

Sample that i have tryed, but without success:

CROSSTABLE ([Brand], [Quantity], 2)

LOAD

F1 as PRODUCT,

BRAND1,

BRAND2,

IF(PRODUCT="TLB", BRAND3, OTHERS)

FROM....

Thanks for any reply

Danilo

10 Replies
IAMDV
Luminary Alumni
Luminary Alumni

Danilo,

Please try this...

IF(PRODUCT='TLB', 'BRAND3', 'OTHERS') AS PRODUCT

Cheers - DV

Not applicable
Author

D V,

Thanks for your reply, but not is this...

Look my complete code...if you see any problem, please tell-me.

ps.: without conditional, loads run =/

[FlashAux]:

CROSSTABLE([Brand], [Quantity],2)

LOAD

  F1      AS [Product],

  makedate($(ano),$(mes)) AS [Date],

[BRAD 1],

BRAND2,

IF(Product='TLB','BRAND3', 'OTHERS') as Product,

BRAND4,

BRAND5,

BRAND6,

BRAND7,

BRAND8,

BRAND9,

OTHERS

FROM [Flash Market\Flash$(var).xls]...

Tks

Danilo

IAMDV
Luminary Alumni
Luminary Alumni

What is the error message? Instead of Product, have you tried using F1 in the function condition. I mean you can't use the alias name with the same load script.

Cheers - DV

Not applicable
Author

DV,

as you have oriented, i need use F1 instead of Product.

But another problem was appeared.

The field was loaded into different table. For it should have been loaded at Brands along with Brand4, 5 and so on, but was loaded in Quantity.

What to do?

Thanks again

Not applicable
Author

Danilo,

I think what you want to do is change your If statement to: IF(F1 = 'TLB','BRAND3','OTHERS') as Brand3.

F1 has yet to be renamed to Product when your if statement executes so you need to reference it as it is in the excel file.

Now, does Brand1-9 exist as fields in the xls file?

IAMDV
Luminary Alumni
Luminary Alumni

Is it possible for you to share the QV document?

Cheers - DV

IAMDV
Luminary Alumni
Luminary Alumni

I think Leonard is right. figures crossed that should resolve the issue.

Cheers - DV

Not applicable
Author

Unfortunally i can't share the QV file, because not is mine..

But the problem now, is:

My conditional was filling the table Quantity insteat of Brand.

I tryed change this:

CROSSTABLE

([Brand], [Quantity],2)

to

------

CROSSTABLE(if([Brand]='BRAND3' and [Product]='TLB', 'BRAND3','OTHERS'), [Quantity],2)

Tks again

-----

Not applicable
Author

Could you provide a better layout of your source data at least for us? Also, what end result are you trying to achieve? What is the purpose of having each Brand in its own column within the source data? Could that be better accomplished in the chart itself?