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: 
imallears
Contributor
Contributor

Grouping calculation

Hi,

I'm hoping this is simple.

I want to group the Instrument with Start and End Dates, and ultimately calculate the total number of weeks attached to each.

I have attached two screenshots below. The 1st is the raw dataset, and the 2nd is what I want to achieve in Qlikview. How do I do it?? Any help would be great.

Thanks

Dataset

Expected Results

 

1 Solution

Accepted Solutions
sunny_talwar

Try this

Table:

LOAD Name,

    Instrument,

    [Start Date],

    [End Date],

    [number of weeks]

FROM

[..\..\..\Downloads\band data.xls]

(biff, embedded labels, table is Sheet1$);


TempTable:

LOAD If(Name = Previous(Name), If(Instrument = Previous(Instrument), Peek('Sort'), RangeSum(Peek('Sort'), 1)), 1) as Sort,

*

Resident Table

Order By Name, [Start Date] desc;


FinalTable:

NoConcatenate

LOAD Name,

Instrument,

Sort,

Min([Start Date]) as [Start Date],

Max([End Date]) as [End Date],

Sum([number of weeks]) as [number of weeks]

Resident TempTable

Group By Name, Instrument, Sort;


DROP Tables Table, TempTable;

Capture.PNG

View solution in original post

3 Replies
vishsaggi
Champion III
Champion III

What is the grouping logic you used here? On what criteria you considered Drums which is coming twice?

sunny_talwar

Try this

Table:

LOAD Name,

    Instrument,

    [Start Date],

    [End Date],

    [number of weeks]

FROM

[..\..\..\Downloads\band data.xls]

(biff, embedded labels, table is Sheet1$);


TempTable:

LOAD If(Name = Previous(Name), If(Instrument = Previous(Instrument), Peek('Sort'), RangeSum(Peek('Sort'), 1)), 1) as Sort,

*

Resident Table

Order By Name, [Start Date] desc;


FinalTable:

NoConcatenate

LOAD Name,

Instrument,

Sort,

Min([Start Date]) as [Start Date],

Max([End Date]) as [End Date],

Sum([number of weeks]) as [number of weeks]

Resident TempTable

Group By Name, Instrument, Sort;


DROP Tables Table, TempTable;

Capture.PNG

imallears
Contributor
Contributor
Author

Excellent. Thank you Sunny