Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
DeepthiVJ
Contributor
Contributor

Variable in set analysis

I am getting error in expression for the below expression for bar chart while i give single quotes around the returning expressions after adding the if condition while calculating sum. i need to add this if condition while doing this calculation. is there any other approach for this?

=if (vLP_OPPORTUNITY='No',
'
Sum(
{<[Error State]={0,3,1}, [Business Unit]-={"FSOLR"}>}
IF(
IF(([Error State]=0 or [Error State]=3 or [Error State]=1),num(round(([Current Price excl CA]-If(Slidr2Name='Any Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level]),
If(Slidr2Name='Same Parent',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level],[Parent Supplier Code]),
If(Slidr2Name='Same Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level],[Supplier Code]),
Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level],[Supplier Site Code])))))*[Part Volume]),'###,###,###'),0) > 0
AND
IF([Error State]=0 or [Error State]=3 or [Error State]=1,num(round(([Current Price]-If(Slidr2Name='Any Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level]),
If(Slidr2Name='Same Parent',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level],[Parent Supplier Code]),
If(Slidr2Name='Same Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level],[Supplier Code]),
Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level],[Supplier Site Code])))))*[Part Volume]),'###,###,###'),0) > 0,
[Current Price] * [Part Volume], 0
)
) - (
Nummax(
Min(
{<[Error State]={0,3,1}, [Business Unit]-={"FSOLR"}>}
IF(
IF(([Error State]=0 or [Error State]=3 or [Error State]=1),num(round(([Current Price excl CA]-If(Slidr2Name='Any Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level]),
If(Slidr2Name='Same Parent',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level],[Parent Supplier Code]),
If(Slidr2Name='Same Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level],[Supplier Code]),
Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level],[Supplier Site Code])))))*[Part Volume]),'###,###,###'),0) > 0
AND
IF([Error State]=0 or [Error State]=3 or [Error State]=1,num(round(([Current Price]-If(Slidr2Name='Any Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level]),
If(Slidr2Name='Same Parent',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level],[Parent Supplier Code]),
If(Slidr2Name='Same Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level],[Supplier Code]),
Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level],[Supplier Site Code])))))*[Part Volume]),'###,###,###'),0) > 0,
[Current Price], 0
)
), 0
) *
Sum(
{<[Error State]={0,3,1}, [Business Unit]-={"FSOLR"}>}
IF(
IF(([Error State]=0 or [Error State]=3 or [Error State]=1),num(round(([Current Price excl CA]-If(Slidr2Name='Any Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level]),
If(Slidr2Name='Same Parent',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level],[Parent Supplier Code]),
If(Slidr2Name='Same Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level],[Supplier Code]),
Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price excl CA],0),[FQPN White Level],[Supplier Site Code])))))*[Part Volume]),'###,###,###'),0) > 0
AND
IF([Error State]=0 or [Error State]=3 or [Error State]=1,num(round(([Current Price]-If(Slidr2Name='Any Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level]),
If(Slidr2Name='Same Parent',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level],[Parent Supplier Code]),
If(Slidr2Name='Same Supplier',Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level],[Supplier Code]),
Aggr(NODISTINCT Min({$<[Error State]={0,3,1}>}[Current Price]),[FQPN White Level],[Supplier Site Code])))))*[Part Volume]),'###,###,###'),0)> 0,
[Part Volume], 0
)
)
)'
,
'
Sum( {<[Error State]={0,3,1}, [Business Unit]-={"FSOLR"}>} [Current Price]*[Part Volume]) -
(
Nummax(Min( {<[Error State]={0,3,1}, [Business Unit]-={"FSOLR"}>} [Current Price]) , 0)
* Sum({<[Error State]={0,3,1}, [Business Unit]-={"FSOLR"}>} [Part Volume])
)'
)

Labels (6)
1 Reply
marksouzacosta

Hi @DeepthiVJ,

FYI, Qlik calculates every single expression inside IF Statements, no matter if the condition is true or false. That is why it is not recommend using If Statements in Measures.

Read more at Data Voyagers - datavoyagers.net