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

Firstsortedvalue function with sum in QlikView

Hello Everyone,

I am using firstsortedvalue function to pick up last value in date field for a particular month. But I would like to combine this with sum function. What I want is, in the attached example, when more than two plants are selected, my graph should display value which is the sum of last value of date field of that particular month combining both plants (sum). How can I achieve this?

Any suggestion?

Thank you.

13 Replies
rubenmarin

Hi, this chart needs to select a week, and each week has one date, can this much simpler expression work?:

If(Month(Date#(POPER_NEW, 'MMM'))>=month(today())

,Sum({<KPI={"Inventory_New"}>}[w/o BB])

,Sum({<KPI={"Inventory_New"}>}[ACT Inventory weekly LC])-Sum({<KPI={"Inventory_New"}>}[AOP Inventory monthly LC])

)

apoorvasd
Creator II
Creator II
Author

Thanks for the suggestion.

But this expression should also work when month is selected. When month is selected, data of last week should be shown in the graph. That's the reason Firstsortedvalue function was used. And when more than two plants are selected, sum of all values of last dates of a month of those plants has to be displayes.

How to achieve this? Any idea?

Thank you.

rubenmarin

Another approach to check first date of the month:

If(Month(Date#(POPER_NEW, 'MMM'))>=month(today()) or WeekShort>=Today()

,Sum(Aggr(If(WeekShort=Min(TOTAL <Plant> WeekShort), Sum({<KPI={"Inventory_New"}>}[w/o BB]))

, Plant, WeekShort))

,Sum(Aggr(

If(WeekShort=Min(TOTAL <Plant> WeekShort),

  Sum({<KPI={"Inventory_New"}>}[ACT Inventory weekly LC])-Sum({<KPI={"Inventory_New"}>}[AOP Inventory monthly LC]))

, Plant, WeekShort))

)

apoorvasd
Creator II
Creator II
Author

Hi Ruben,

This expression is working

I have changed "Min" to "Max" as I wanted last date of the month and the expression is working as expected.

Thank you very much!