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

Loading Average Values from table to Qlikview

I have a kind of following table in excel sheet.

CountryMonth.YearPopulationLife Expectancy
A06.2011100070
A12.2011140072
A06.2012200074
A12.2012220076
B06.2011

1200

68
B12.2011140070
B06.2012160072
B12.2012180074

While loading the information from this table, I want the following kind to tebale format loaded to the QlikView. The values of population and life expectancy should be averaged for each city for each year.

CountryYearAvg PopulationAvg Life Expectancy
A2011120071
A2012210075
B2011130069
B2012170073

How should the load statement look like..?? Please help..

Thanks in advance..!!!

1 Solution

Accepted Solutions
PrashantSangle

Hi,

It is easily you can acheive.

In load script create Year Field

using Year()

Like

Load *,

Year(Month.Year) as newYear     //If your MOnth.year field is Date format if not then

Year(Date#(Month.Year,'MM.YYYY')) as NewYear1 //or you can

subfield(Month.Year,'.',1) as NewYear2

From tablename

Then

In GUI

use Straight Table chart

USe Country and one of the NewYear Field as your Dimension

and

In Expression Write

1) Avg(Population)

2)Avg([Life Expentancy])

It will give you desired result.

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

4 Replies
MK_QSL
MVP
MVP

Temp:

Load *, Right(Month.Year,4) as Year Inline

[

  Country, Month.Year, Population, Life Expectancy

  A, 06.2011, 1000, 70

  A, 12.2011, 1400, 72

  A, 06.2012, 2000, 74

  A, 12.2012, 2200, 76

  B, 06.2011, 1200, 68

  B, 12.2011, 1400, 70

  B, 06.2012, 1600, 72

  B, 12.2012, 1800, 74

];

Final:

Load

  Country,

  Year,

  Avg(Population) as [Avg Population],

  Avg([Life Expectancy]) as [Avg Life Expectancy]

Resident Temp

Group By Country, Year;

Drop Table Temp;

MK_QSL
MVP
MVP

On the Front End ...

Use below Script...

Temp:

Load *, Right(Month.Year,4) as Year Inline

[

  Country, Month.Year, Population, Life Expectancy

  A, 06.2011, 1000, 70

  A, 12.2011, 1400, 72

  A, 06.2012, 2000, 74

  A, 12.2012, 2200, 76

  B, 06.2011, 1200, 68

  B, 12.2011, 1400, 70

  B, 06.2012, 1600, 72

  B, 12.2012, 1800, 74

];

Create a Straight Table

Dimension

Country

Year

Expressions

1) Avg(Population)

2) Avg([Life Expectancy])

PrashantSangle

Hi,

It is easily you can acheive.

In load script create Year Field

using Year()

Like

Load *,

Year(Month.Year) as newYear     //If your MOnth.year field is Date format if not then

Year(Date#(Month.Year,'MM.YYYY')) as NewYear1 //or you can

subfield(Month.Year,'.',1) as NewYear2

From tablename

Then

In GUI

use Straight Table chart

USe Country and one of the NewYear Field as your Dimension

and

In Expression Write

1) Avg(Population)

2)Avg([Life Expentancy])

It will give you desired result.

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

Thanks Max..