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

Comparing the two dates and getting max value(MTD)

Hi , I have the date as shown below:

DateMTDTOTAL
01-01-1710
02-01-174
03-01-1715
01-02-176
02-02-1720
03-02-170
01-03-1711
02-03-178

The expected result is as shown below in MTDPEAKTOTAL column. But what I am getting is as shown in  the TEST Coulmn wherein I am using the expression as  Rangemax(above(total sum(MTDTOTAL),0,rowno(TOTAL)) i.e  when it encounter next month it should start comparing with the first day value of that month which is not happening.

I tried doing in backend using the peek function

if(rowno()=1,MTDTOTAl,

if(MONTHYEAR = PEEK(MONTHYEAR) and MTDTOTAL>PEEK(MTDPEAKTOTAL),MTDTOTAL,PEEK(MTDPEAKTOTAL))  as MTDPEAKTOTAL. This expression works completely fine but the problem is I have 10 different metrics for each metrics it has to do. So at each metric level it is not coming correctly. Kindly guide me suitable Suggestion. Thanks in Advance.

DAteMTDTOTALMTDPEAKTOTALTEST
01-01-17101010
02-01-1741010
03-01-17151515
01-02-176615
02-02-17202020
03-02-1702020
01-03-17111120
02-03-1781120
2 Replies
Kushal_Chawda

Can you share the sample data at least for two metrics?

daveamz
Partner - Creator III
Partner - Creator III

Hi,

Check the script in the attachment.

Regards,

David