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

Count

Hi All

can any one help me on the following scenario, I have 3 fields   Design Date, Sale Date Item , Sale, by using these three fields I would like to calculate Total Months count for each Item from Design date and cumulative sum of Sale for each item to Sale date.

Thanks

John

18 Replies
PradeepReddy
Specialist II
Specialist II

try bellow expression for cumulative sum.. (Pivot Table)

Dimension: Item,Sale Date

expr1: Sum(Sale)

expr2: if(isnull(above(sum(Sale),1))=1,sum(Sale),rangesum(sum(Sale),above(sum(Sale),1)))

miguelbraga
Partner - Specialist III
Partner - Specialist III

1. =Sum(MonthsDifference)

2. = aggr( NODISTINCT sum(Sale), Item ) OR max(Aggr(sum(Sale),Item)), depending on how you want to show the results.

Hope it helps

Not applicable
Author

No Luck

Not applicable
Author

Hi Miguel Braga, Could you please explain me how the

MonthDiff  variable will function here?

miguelbraga
Partner - Specialist III
Partner - Specialist III

MonthDiff will function based on how your start date ence [Design Date] is and your end date in your case [Sale Date]. I'm working on the count expression

sunny_talwar

Unable to get the results in months, but for days may be this:

Table:

LOAD [Design Date],

    [Sale Date],

    Item,

    Sale

FROM

[Testdata (3).xlsx]

(ooxml, embedded labels, table is Sheet1);

Concatenate(Table)

LOAD Only(Item) as Item,

  Date(Today()) as [Design Date],

    Date(Today()) as [Sale Date],

    0 as Sale

Resident Table

Group By Item;

Join(Table)

LOAD Min([Sale Date]) as [Min Sale Date],

  Item

Resident Table

Group By Item;

FinalTable:

LOAD *,

  [Sale Date] - [Min Sale Date] as DaysDifference,

  If(Item = Peek('Item'), RangeSum(Peek('Cumulative Mileage'), Sale), Sale) as [Cumulative Mileage]

Resident Table

Order By Item, [Sale Date];

DROP Table Table;


Capture.PNG

Not applicable
Author

Hi Sunny Thanks, in the Model final table

one more load with Load *,  Round(DaysDifference/30.4166666667) As DiffMonth ;

will give us Months.

Thanks again.

sunny_talwar

Awesome