Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
YG
Contributor III
Contributor III

Qlik Sens - Dividing Sums by assigning variables

Hi All,

 

I have a table below table, I want to divide  FY19 =112.10/FY20 = 90.40. I am new to this, How do I assign  x(FY19 =112.10) and y(FY20 = 90.40) So I can get KPI value. I do not like to hard code the values as FY20 is on going and will change as it progress. So would like to do as an expression. Anyone can help would be appreciated 

2 columns table2 columns table

Labels (3)
2 Solutions

Accepted Solutions
Anil_Babu_Samineni

Create one field in script like

Year(Num#(Right(FYear,2))) as FYear_Copy

Then, In the KPI you can define as below

Num(Avg({<FYear_Copy={$(=Max(FYear_Copy-1))}>} Resolve_time)/3600, '##.00')/Num(Avg({<FYear_Copy={$(=Max(FYear_Copy))}>} Resolve_time)/3600, '##.00')

Or, May be without field creation you can use

Num(Avg({<FYear={$(=MaxString(FYear))}>} Resolve_time)/3600, '##.00')/Num(Avg({<FYear={$(=MaxString(FYear))}>} Resolve_time)/3600, '##.00')

Or, If you already have some field related Financial Year, You can even try

Num(Avg({<Fin_Year={$(=Max(Fin_Year-1))}>} Resolve_time)/3600, '##.00')/Num(Avg({<Fin_Year={$(=Max(Fin_Year))}>} Resolve_time)/3600, '##.00')

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

View solution in original post

YG
Contributor III
Contributor III
Author

Thanks Anil, I went down the path you suggested,

I created a new Dimension  called =  FYear_New using below  expression

Num#(Right(FYear,2)) 

Then Created a Measure :

Num(Avg({<FYear_New={$(=Max(FYear_New))}>} Resolve_time)/3600, '##.00')/
Num(Avg({<FYear_New={$(=Max(FYear_New-1))}>} Resolve_time)/3600, '##.00')

 

Thanks for all your help

 

 

View solution in original post

4 Replies
Anil_Babu_Samineni

Create one field in script like

Year(Num#(Right(FYear,2))) as FYear_Copy

Then, In the KPI you can define as below

Num(Avg({<FYear_Copy={$(=Max(FYear_Copy-1))}>} Resolve_time)/3600, '##.00')/Num(Avg({<FYear_Copy={$(=Max(FYear_Copy))}>} Resolve_time)/3600, '##.00')

Or, May be without field creation you can use

Num(Avg({<FYear={$(=MaxString(FYear))}>} Resolve_time)/3600, '##.00')/Num(Avg({<FYear={$(=MaxString(FYear))}>} Resolve_time)/3600, '##.00')

Or, If you already have some field related Financial Year, You can even try

Num(Avg({<Fin_Year={$(=Max(Fin_Year-1))}>} Resolve_time)/3600, '##.00')/Num(Avg({<Fin_Year={$(=Max(Fin_Year))}>} Resolve_time)/3600, '##.00')

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
YG
Contributor III
Contributor III
Author

Thanks Anil. I chose to go with the ,

Num(Avg({<FYear={$(=MaxString(FYear))}>} Resolve_time)/3600, '##.00')/

Num(Avg({<FYear={$(=MaxString(FYear))}>} Resolve_time)/3600, '##.00')

 

Answer however was  = 1 

The out put was correct as per the pic its  (90.40/90.40)

It should be 112.10/90.40 instead

I tried,

Num(Avg({<FYear={$(=MaxString(FYear-1))}>} Resolve_time)/3600, '##.00')/

Num(Avg({<FYear={$(=MaxString(FYear))}>} Resolve_time)/3600, '##.00')

Also

Num(Avg({<FYear={$(=MaxString(FYear)-1)}>} Resolve_time)/3600, '##.00')/

Num(Avg({<FYear={$(=MaxString(FYear))}>} Resolve_time)/3600, '##.00')

both actually gave me an answer "-"

However,

Num(Avg({<FYear={$(=MinString(FYear))}>} Resolve_time)/3600, '##.00') = 158.38

Is there away to get MaxSrting()- 1?

 

Anil_Babu_Samineni

MaxString() returns based on Power of Character string length. I won't perform, IF i have same task. Instead how about other suggestion?

However, What it is returning MaxString(FYear) and MaxString(FYear)-1

If this is String (FYear) - MaxString(FYear)-1 this won't work.

 

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
YG
Contributor III
Contributor III
Author

Thanks Anil, I went down the path you suggested,

I created a new Dimension  called =  FYear_New using below  expression

Num#(Right(FYear,2)) 

Then Created a Measure :

Num(Avg({<FYear_New={$(=Max(FYear_New))}>} Resolve_time)/3600, '##.00')/
Num(Avg({<FYear_New={$(=Max(FYear_New-1))}>} Resolve_time)/3600, '##.00')

 

Thanks for all your help