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: 
mahnoor1279
Contributor III
Contributor III

How to load only date where higher the sum of values in each month

Hey everyone,

I've task to show the highest amount for  day of month where the sum of value in greater  then rest of the days of that specific month.

 

TEST1:
LOAD
FUND_NO,
AMOUNT
DATE

FROM [lib://DataExtractor (qsense)/TRANSACTION.qvd]
(qvd);


NoConcatenate
TEST2:

LOAD FUND_NO,SUM(AMOUNT)) AS gross_amount

Resident TEST1
GROUP BY FUND_NO,DATE;
DROP TABLE TEST1;


NoConcatenate
TEST3:

LOAD DATE, MAX(gross_amount) AS gross_amount

Resident TEST2
GROUP BY DATE;
DROP TABLE TEST2;

 

DESIRED RESULT 

201026113 07/05/2023

764246324

 

SAMPLE DATA:

 

FUND_NO DATE SUM(AMOUNT)
201026113 02/05/2023 2434246
201026113 03/05/2023 1364210
201026113 04/05/2023 353235
201026113 15/05/2023 15642
201026113 06/05/2023 1258624
201026113 07/05/2023 764246324
201026113 11/05/2023 4574243
201026113 09/05/2023

3457430

Labels (4)
1 Solution

Accepted Solutions
joaopaulo_delco
Partner - Creator III
Partner - Creator III

Hi @mahnoor1279 

Try the code below:

[TEST]:
LOAD
	FUND_NO,
	AMOUNT,
	DATE,
    MonthName(DATE) as MONTH_YEAR
FROM [lib://Temp/Fonte Help Community.xlsx]
(ooxml, embedded labels, table is Planilha1);

NoConcatenate

[AUX_1]:
LOAD
	FUND_NO,
	Sum(AMOUNT) as TOTAL_AMOUNT,
	DATE,
    MONTH_YEAR
Resident TEST 
group by FUND_NO, MONTH_YEAR, DATE;    
Drop Table TEST;

NoConcatenate
[FINAL]:
LOAD FUND_NO,
     FirstSortedValue(DATE, -TOTAL_AMOUNT) as Data_Top,
     Max(TOTAL_AMOUNT) 					   as TOTAL_AMOUNT
Resident AUX_1 
Group By FUND_NO, MONTH_YEAR;
Drop Table AUX_1;
Help users find answers! Don't forget to mark a solution that worked for you!

View solution in original post

4 Replies
joaopaulo_delco
Partner - Creator III
Partner - Creator III

Hi, @mahnoor1279!

           If you need to do it in a chart, you can use the expression like the screenshot below:

joaopaulo_delco_0-1689103503662.png

I also add the qvf file attached. 

Help users find answers! Don't forget to mark a solution that worked for you!
mahnoor1279
Contributor III
Contributor III
Author

But how can we do it on script editor ?

joaopaulo_delco
Partner - Creator III
Partner - Creator III

Hi @mahnoor1279 

Try the code below:

[TEST]:
LOAD
	FUND_NO,
	AMOUNT,
	DATE,
    MonthName(DATE) as MONTH_YEAR
FROM [lib://Temp/Fonte Help Community.xlsx]
(ooxml, embedded labels, table is Planilha1);

NoConcatenate

[AUX_1]:
LOAD
	FUND_NO,
	Sum(AMOUNT) as TOTAL_AMOUNT,
	DATE,
    MONTH_YEAR
Resident TEST 
group by FUND_NO, MONTH_YEAR, DATE;    
Drop Table TEST;

NoConcatenate
[FINAL]:
LOAD FUND_NO,
     FirstSortedValue(DATE, -TOTAL_AMOUNT) as Data_Top,
     Max(TOTAL_AMOUNT) 					   as TOTAL_AMOUNT
Resident AUX_1 
Group By FUND_NO, MONTH_YEAR;
Drop Table AUX_1;
Help users find answers! Don't forget to mark a solution that worked for you!
mahnoor1279
Contributor III
Contributor III
Author

Thanks alot