Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Mukesh_s
Contributor II
Contributor II

Sum(Case When

Hi, I need help in converting the below SQL querys to qlik scripting.

[ConvAdv] = SUM(CASE WHEN [AdvanceProduct] = 123 THEN [OutstandingBalance] END)

[Overdrawn] = ABS(SUM([BookBalanceAfterInterestEOD]))

 

Thanks in Advance.

Labels (2)
1 Solution

Accepted Solutions
Swetha12
Contributor
Contributor

Hello Mahesh,

Please try with this,

Sum(If(AdvanceProduct = 123 and OutstandingBalance,OutstandingBalance)) as ConvAdv

 

 

View solution in original post

3 Replies
Benoit_C
Support
Support

Hello @Mukesh_s,

 

I believe it should be:

 

[ConvAdv] = SUM(IF([AdvanceProduct] = 123, [OutstandingBalance]))

 


Regards,

Benoit

Swetha12
Contributor
Contributor

Hello Mahesh,

Please try with this,

Sum(If(AdvanceProduct = 123 and OutstandingBalance,OutstandingBalance)) as ConvAdv

 

 

Renatusfreitas
Partner - Contributor III
Partner - Contributor III

@Mukesh_s  envie uma amostra de dados, para que possa compreender melhor a sua necessidade, fiz aqui uma pequena amostra, mas precisaria avaliar mehor o seu objetivo.

//[ConvAdv] = SUM(CASE WHEN [AdvanceProduct] = 123 THEN [OutstandingSaldo] END)

 

Fiz essa leitura :

//Se [AdvanceProduct] = 123 então Soma([OutstandingSaldo]) 

//[ConvAdv] = [OutstandingSaldo]

 

[Teste]:
Load *
Inline [
ConvAdv, AdvanceProduct, OutstandingSaldo
15, 123, 10
20, 123, 9
15, 122, 15
];

Teste1:
Load
*,
If(ConvAdv = "Nome Campo", 'OK') AS 'Status'
;
Load
AdvanceProduct,
Sum(ConvAdv) As 'ConvAdv',
If(Match("AdvanceProduct", 123), Sum("OutstandingSaldo")) As 'OutstandingSaldo'     //SUM(CASE WHEN [AdvanceProduct] = 123 THEN [OutstandingSaldo] END)

resident Teste
Group By AdvanceProduct
;

exit script;

 

 

seria interessante enviar uma amostra para uma melhor compreensão. 👌🏽

Se está solução ajudou, aceite-a como uma solução.

https://br.linkedin.com/in/renatusfreitas

https://cubotimize.com/