Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
piter89
Contributor II
Contributor II

How to compute the max value for dimension in a column and add it to all rows

Hello,

I have a table with products. The Product field is dimension in the table. 

Product //dimension Max value //1. measure Amount //2. measure
Backpack 5 5
Pen 1 1
Chalk 4 4

Two measure as follows:
1. 

Max(Aggr( Sum({< YearMonth={'$(= $(vMaxMonth))'}, [Product] >} total<[Product]> [Amount]),Product))    // bad result in table, good result in KPI 


2. 

Sum({<  YearMonth={'$(= $(vMaxMonth))'} >}[Amount])



I would like to get the table as bellow:

Product //dimension Max value //1. measure Amount //2. measure
Backpack 5 5
Pen 5 1
Chalk 5 4


The 'max value' column should show the higher value for any product in amount measure. I tried to use FirstSortedValue function, but it also failed.

FirstSortedValue(Product, Aggr(Max({< [YearMonth]={'$(= $(vMaxMonth))'}, [Product] >}[Amount]), Product))



Thank you for your help 

Labels (1)
1 Reply
deepanshuSh
Creator III
Creator III

By Add to all rows, do you intend to add the max amount to all the amount values, or do you want a separate column just showcasing the max(value)?

If its the latter, then Aggr(max(Amount), Product), 

If summation is needed as well then, Sum(Aggr(max(Amount), Product))

Trial and error is the key to get unexpected results.