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

Help in accumulation formulas (Replacing above)

I have a straight table with the KPI values by Month and Year, I want to show in this same table some expressions:

1. The variation between the current Month and the Previous

2. The accumulated variations (1) along the current year

3. The variation between the current Month and the same Month on the last Year (12 Months variation)

I've already built all the expressions, however the last one makes the table show all the years I have in my table because is using 1 as the set identifier. How can I replace this and keep only the selected period with the correct accumulations?

Expression 3 disabled:

tabela1.png

Expression 3 enabled:

tabela2.png

Expression 3 formula:

if(

          sum({1<[Descrição do Subindicador]={'CUB-PR'}>} Valor)>0,

          if(

                    IsNull(above(total sum({1<[Descrição do Subindicador]={'CUB-PR'}>} Valor))),

                    0,

                    ((

                              sum({1<[Descrição do Subindicador]={'CUB-PR'}>} Valor)

                              /

                              above(total sum({1<[Descrição do Subindicador]={'CUB-PR'}>} Valor),12,0)

 

                    -1)*100

                    )

          )

)

Can someone help me please?

1 Solution

Accepted Solutions
cesaraccardi
Specialist
Specialist
Author

Hi,

The problem was solved.. I used the Only() in the expression with AddMonths like you said however for this to work I must have 1 select value for year, as my client agreed with this, so that's ok.

Thanks for your help!

View solution in original post

6 Replies
Not applicable

Try using Monthname Functions with AddMonths(Date,-12) You could use this in SET to avoid using above

whiteline
Master II
Master II

You can add  years to all of your sets:

{1<[Descrição do Subindicador]={'CUB-PR'}, Year=P({$}Year)>}

cesaraccardi
Specialist
Specialist
Author

Hi,

thanks for the quick response...  Like this?

sum({$<[Descrição do Subindicador]={'CUB-PR'},Ano={"$(=Year(AddMonths(Date#([Ano Mês],'YYYY/MMM'),-12)))"}>} Valor)

If put the modifier expression in a new the result appears to be correct (last year), however the expression "12 Meses" doesn't show any value:

tabela3.png

cesaraccardi
Specialist
Specialist
Author

Thanks.

I tried this.... but I need to calculate the variation with a year (2010) that is outside of my selection. Any ideas?

whiteline
Master II
Master II

I think, you can always use Only() over your expression with corresponding set expression.

cesaraccardi
Specialist
Specialist
Author

Hi,

The problem was solved.. I used the Only() in the expression with AddMonths like you said however for this to work I must have 1 select value for year, as my client agreed with this, so that's ok.

Thanks for your help!