Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
mohan2391
Creator III
Creator III

Monthly bar chart - help

I have 2 date columns

Date1, Date2, Sales

Jan24, Jan24, 100

Jan24, Feb24, 110

Feb24, Feb24, 200

Feb24, Mar24, 210

Mar24, Mar24, 300

Mar24, Apr24, 310

I have to show a bar chart with

DIMENSION = Date1

MEASURE = Sum(Sales) for Date2 as next month

I mean, Jan24 bar should show 110, Feb24 bar should show 210 and Mar24 bar should show 310.

How to write set expression.

1 Solution

Accepted Solutions
dmac1971
Creator III
Creator III

Does this work for you :

tmpData:

LOAD * Inline [

Date1, Date2, Sales

01/01/2024, 01/01/2024, 100
01/01/2024, 01/02/2024, 110
01/02/2024, 01/02/2024, 200
01/02/2024, 01/03/2024, 210
01/03/2024, 01/03/2024, 300
01/03/2024, 01/04/2024, 310

];

Data:
NoConcatenate Load *, If(Date2> Date1,1,0) As DateCheck Resident tmpData; Drop Table tmpData;

 

Then expression is : sum({<DateCheck = {'1'}>}Sales)

Gives:

dmac1971_1-1718120951883.png

 

 

View solution in original post

4 Replies
dmac1971
Creator III
Creator III

Does this work for you :

tmpData:

LOAD * Inline [

Date1, Date2, Sales

01/01/2024, 01/01/2024, 100
01/01/2024, 01/02/2024, 110
01/02/2024, 01/02/2024, 200
01/02/2024, 01/03/2024, 210
01/03/2024, 01/03/2024, 300
01/03/2024, 01/04/2024, 310

];

Data:
NoConcatenate Load *, If(Date2> Date1,1,0) As DateCheck Resident tmpData; Drop Table tmpData;

 

Then expression is : sum({<DateCheck = {'1'}>}Sales)

Gives:

dmac1971_1-1718120951883.png

 

 

TauseefKhan
Creator III
Creator III

Hi @mohan2391 

TauseefKhan_0-1718161862776.png

 


Dimension: Use Date1.
Measure: Use Sum(SalesForNextMonth).

RawData:
LOAD
Date1,
Date2,
Sales
INLINE [
Date1, Date2, Sales
Jan24, Jan24, 100
Jan24, Feb24, 110
Feb24, Feb24, 200
Feb24, Mar24, 210
Mar24, Mar24, 300
Mar24, Apr24, 310
];

NextMonthSalesMap:
MAPPING LOAD
Date1,
Sales AS NextMonthSales
RESIDENT RawData
WHERE Date1 <> Date2;

FinalData:
LOAD
Date1,
ApplyMap('NextMonthSalesMap', Date2, 0) AS SalesForNextMonth
RESIDENT RawData
WHERE Date1 = Date2;

DROP TABLE RawData;

Hope this resolve your issue.
When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions").

mohan2391
Creator III
Creator III
Author

Thanks a lot dmac1971. It worked perfectly.

mohan2391
Creator III
Creator III
Author

Thank You TauseefKhan for responding to my question and your suggestion.

The other logic worked fine for me, so didn’t implement in my application.

But your logic seems also working, have tested with some sample data, Thank You.