Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
varunvarma
Contributor III
Contributor III

SET analysis required.

Dear All,

Greetings for the day.

Please guide me to achieve below requirement. Please find the attachment for sample data.

I need to create a pivot table

DIMENSION :- TEST_YEAR

EXPRESSION :- FORMULA (Please find the image below).

Capture.PNG

For TEST_YEAR (2015) --> I mentioned formula in above image.
i.e (value of TEST_COUNT FOR MIN(TEST_SALEYEAR)(6) * (TEST_YEAR - TEST_SALEYEAR(MIN)) + ......)/ (SUM OF ALL TEST_COUNT FOR TEST_YEAR).

Hope you understand my requirement. Please support. Thanks in advance.

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

In attached file I tried like this

Chart : Pivot Table

Dimension: TEST_YEAR

Expression:

=If(TEST_YEAR = Year(Today()) + 1,

Sum(Aggr((TEST_YEAR - TEST_SALEYEAR) * TEST_COUNT, TEST_YEAR, TEST_SALEYEAR))/

Sum(TEST_COUNT),

Sum(TEST_COUNT))

Hope this helps you.

Regards,

jagan.

View solution in original post

8 Replies
varunvarma
Contributor III
Contributor III
Author

Dear All,

Any solution for above requirement ???

jyothish8807
Master II
Master II

Hi varun,

Try this expression:

Take Test Year as dimension.

In expression:

  aggr(firstsortedvalue(TEST_COUNT,TEST_SALEYEAR),TEST_YEAR)*((TEST_YEAR)-aggr(min(TEST_SALEYEAR),TEST_YEAR))/sum(Total <TEST_YEAR> TEST_COUNT)

Regards

KC

Best Regards,
KC
jagan
Luminary Alumni
Luminary Alumni

Hi,

Please find attached file for solution.

Regards,

jagan.

jyothish8807
Master II
Master II

This is for just one value, if you want to keep incresing the min(Year) then you have to use loop concept and create a script in the backend.

Regards

KC

Best Regards,
KC
jagan
Luminary Alumni
Luminary Alumni

Hi,

In attached file I tried like this

Chart : Pivot Table

Dimension: TEST_YEAR

Expression:

=If(TEST_YEAR = Year(Today()) + 1,

Sum(Aggr((TEST_YEAR - TEST_SALEYEAR) * TEST_COUNT, TEST_YEAR, TEST_SALEYEAR))/

Sum(TEST_COUNT),

Sum(TEST_COUNT))

Hope this helps you.

Regards,

jagan.

varunvarma
Contributor III
Contributor III
Author

Thank you jagan garu..Because of no time i completed in back end but this is really help me.

jyothish8807
Master II
Master II

Hi ,

Can you share the script you used in the backend?

Regards

KC

Best Regards,
KC
varunvarma
Contributor III
Contributor III
Author

Hi,

Please look below.  

BASE:

LOAD TEST_YEAR,
TEST_SALEYEAR,
TEST_VIN_No
FROM
FINALTEST.QVD
(
qvd);

TEMP:
LOAD
TEST_YEAR,
TEST_SALEYEAR,
Count(DISTINCT TEST_VIN_No) as TEST_COUNT
Resident BASE
GROUP BY TEST_YEAR,TEST_SALEYEAR;

DROP Table BASE;

FINAL:
LOAD *,
(
TEST_COUNT)* ( NUM((TEST_YEAR) - (TEST_SALEYEAR))) AS FIN_MUL
Resident TEMP;
DROP Table TEMP;

Dim :- TEST_YEAR

Exp :-

=

round((SUM(FIN_MUL))
/
SUM(TEST_COUNT) )

It is almost same as jagan's expression.