Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
ioannagr
Creator III
Creator III

Help with set analysis aggr max

Hi a have a dimension field, let's call it 

Client and for each client i have a different max(visitdate)

I want to make a table to present the columns : client, max visitdate for each client and  for each max visit date for each client the amount of available items purchased so i did :

Client,      aggr(max([visitdate]),[Client])  ,   sum({<[visitdate]={"=aggr(max([visitdate],[Client]))" },[Availabity]={'available'}>} [amount purchased])

but the expression in bold is wrong!

What is it i do wrong?

18 Replies
Anil_Babu_Samineni

Perhaps this for bold expression?

Max(Aggr(sum({<[visitdate]={"=aggr(max([visitdate],[Client]))" },[Availabity]={'available'}>} [amount purchased]), client))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
ioannagr
Creator III
Creator III
Author

Hey @Anil_Babu_Samineni ,No, just "-"  presented 😕

Kushal_Chawda

@ioannagr  Try below

Dimensions:

1) Client

2) aggr(max([visitdate]),[Client])  

Expression:

sum({<[Availabity]={'available'}>} [amount purchased])

ioannagr
Creator III
Creator III
Author

Hi @Kushal_Chawda , still nothing. It looks like it doesn't take into account the max(visitdate), shows the total of available items this client has ever purchased

Kushal_Chawda

@ioannagr  try below

=sum({<[Availabity]={'available'}>}aggr(if(Date=max(total <Clinet> Date),Sales),Clinet, Date))

ioannagr
Creator III
Creator III
Author

@Kushal_Chawda  now it gives me 0's everywhere 😕 Do you perhaps have another idea?

ioannagr
Creator III
Creator III
Author

@Kushal_Chawda @Anil_Babu_Samineni let me explain to you what is happening.

I do a straight table with columns, client, aggr(max([visitdate]),[Client])  and then if I try  aggr(sum( {<[date={ '$(= max([date]))' },[availability]={'available'} >} [amount purchased]),[client])

This strange thing happens : For only one client I get the correct sum for their max(visitdate) and for the rest I get "-"s.

BUT if i click on another client's name (that also has a different max date) , the "- " changes to the expected number.

 

What is this now? 

 

tresesco
MVP
MVP

@ioannagr , Try like:

Dimensions:

1) Client

Expression:

1) date(max([visitdate])) 

2) FirstSortedValue({<[Availabity]={'available'}>} Aggr(sum({<[Availabity]={'available'}>} [amount purchased]), Client) , - [visitdate])

Or,

FirstSortedValue({<[Availabity]={'available'}>} Aggr(sum( [amount purchased]), Client) , - [visitdate])

ioannagr
Creator III
Creator III
Author

Hello @tresesco , just "-"s everywhere. 😞

When you mention dimension you mean not a master item dimension, just select dimension instead of measure in the straight table, right?