Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
deep2021
Creator III
Creator III

unable to calculate the qlik view if condition in qlik sense

Hi,

I have a Timespan column having values 3M, 12M, MTD.

In qlikview the if condition is working fine.

But the same if condition is not working in qliksense.

The if condition is as per the below,

=f(Timespan='MTD', sum(TOTAL{$<Timespan=,[Report Level]={'1'},Month={"$(v_MonthNoLM)"}>}HC_RSK_TE_MTD),0)

Could you please suggest on this.

Thanks

Labels (4)
5 Replies
Chanty4u
MVP
MVP

first test the expression values is showing proper or not?

=if(Timespan='MTD', 1,0)   returns 1 or not check this first 

then try below

test this in kpi object is it showing correct or not

sum(TOTAL{$<Timespan=,[Report Level]={'1'},Month={"$(v_MonthNoLM)"}>}HC_RSK_TE_MTD)

if yes put it in Variable 

vMTD=sum(TOTAL{$<Timespan=,[Report Level]={'1'},Month={"$(v_MonthNoLM)"}>}HC_RSK_TE_MTD)

use below

=if(Timespan='MTD',$(vMTD) ,0)   

 

 

deep2021
Creator III
Creator III
Author

Hi,

I tried but no luck. Same issues. I suspect there are some issues with Timespan. Whenever I am trying to conert the column into numbers it is showing nulls.

The output of num(Timespan) is null. Same for Text(Timespan).

Thanks

Chanty4u
MVP
MVP

how timespan is derived ?

deep2021
Creator III
Creator III
Author

The timespan is just the column, and it is not derived in the QS data model.

Whenever I am exporting the column in the excel, it is showing the data type as General.

Do I have to do anything is these aspect?

Also the if condition is like below,

if(Timespan='MTD',

if([Factor Type]='Total',sum(TOTAL{$<Timespan=,[Report Level]={'1'},Month={"$(v_MonthNoLM)"}>}HC_RSK_TE_MTD),
if([Factor Type]='Style',sum( TOTAL{$<Timespan=,[Report Level]={'1'},Month={"$(v_MonthNoLM)"}>}HC_RSK_TE_RESIDUAL_STY_MTD),
if([Factor Type]='Industry',sum( TOTAL{$<Timespan=,[Report Level]={'1'},Month={"$(v_MonthNoLM)"}>}HC_RSK_TE_RESIDUAL_IND_MTD),
if([Factor Type]='Currency',sum( TOTAL{$<Timespan=,[Report Level]={'4'},FT={'FX'},Month={"$(v_MonthNoLM)"}>}HC_RSK_TE_RESIDUAL_MTD),
if([Factor Type]='Mkt Timing',sum( TOTAL{$<Timespan=,[Report Level]={'1'},Month={"$(v_MonthNoLM)"}>}HC_RSK_TE_MKT_TIMING_MTD),
if([Factor Type]='Specific',sum( TOTAL{$<Timespan=,[Report Level]={'1'},Month={"$(v_MonthNoLM)"}>}HC_RSK_TE_SPECIFIC_RESIDUAL_MTD),
if([Factor Type]='Spreads',sum( TOTAL{$<Timespan=,[Report Level]={'1'},Month={"$(v_MonthNoLM)"}>}TE_RESIDUAL_SPREADS)/(100*sqrt(12)),
if([Factor Type]='Term Structure',sum( TOTAL{$<Timespan=,[Report Level]={'1'},Month={"$(v_MonthNoLM)"}>}TE_RESIDUAL_RATES)/(100*sqrt(12)),
if([Factor Type]='Country',sum( TOTAL{$<Timespan=,[Report Level]={'1'},Month={"$(v_MonthNoLM)"}>}HC_RSK_TE_RESIDUAL_CTY_MTD))))))))))
,0)

 

Is there any issues because of the nested if statements?

When i checked separately, the inner if conditions are working fine, and there is issue related to the outer one.

 

Anil_Babu_Samineni

It's not working means, What is the error?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful