Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
BenjaminCoe1440
Contributor III
Contributor III

Grouping current month and last month in a bar chart

I need to compare the current month against last month in a bar chart and I need it look like the 7-day rolling bar chart, but I need to retain the date value. When the bar chart is day of the week (instead of date), this week vs last week is grouped automatically. (NB: 30-day rolling comparison legend is incorrect and should say this month, last month) How do I make a side-by-side comparison for the second chart?

 

Thanks in advance

Ben

BenjaminCoe1440_0-1667229020934.pngBenjaminCoe1440_1-1667229046024.png

 

Labels (3)
2 Solutions

Accepted Solutions
vinieme12
Champion III
Champion III

Create a new field based on your Date field as below

either in load script while loading data

Day(Datefield) as DayNum

Then use DayNum as dimension in chart

 

Or in chart use below calculated dimension

Dimension

=Day(Datefield) 

=Month

 

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

vinieme12
Champion III
Champion III

Create a Dual() value field  as below

 

example

 

DummyData:
Load
Date
,Day(Date) as DayNum
,MonthName(Date) as Monthname
,Dual(Text(Date),Day(Date)) as DayText
,ceil(Rand()*100) as randomval
;
load date(today()-recno()) as Date
AutoGenerate(90);

 

 

Then in Chart use the Field DayText as dimension

example Measures:

CurrentMonth

sum({<Date={">=2022-10-01<=2022-10-30"}>}randomval)

PReviousMonth

sum({<Date={">=2022-09-01<=2022-09-31"}>}randomval)

 

Capture.PNG

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

6 Replies
vinieme12
Champion III
Champion III

Just use the Day dimension that has value 1,2,3,4,5,---30/31

you cannot have dates like 1-Jan-2022 Next to 1-Feb-2022

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
BenjaminCoe1440
Contributor III
Contributor III
Author

Thanks - but how do I replace the current dimension with your suggestion? When I add 'Day' into the Field section, I get the following:

Before:

BenjaminCoe1440_0-1667290270061.png

After:

BenjaminCoe1440_1-1667290576499.png

Definition of 'previous 30 days' measure for context:

BenjaminCoe1440_2-1667290693350.png

 

 

 

vinieme12
Champion III
Champion III

Create a new field based on your Date field as below

either in load script while loading data

Day(Datefield) as DayNum

Then use DayNum as dimension in chart

 

Or in chart use below calculated dimension

Dimension

=Day(Datefield) 

=Month

 

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
BenjaminCoe1440
Contributor III
Contributor III
Author

 

Got DayNum but can I overlay this with the actual dates for the first measure (i.e. current 30-days) on the bar chart 

 

(In below example, 1 = 26/09/2022, 2 = 27/09/2022, etc...)

BenjaminCoe1440_0-1667313097457.png

BenjaminCoe1440_1-1667313216775.png

Thanks again

 

Ben

 

vinieme12
Champion III
Champion III

Create a Dual() value field  as below

 

example

 

DummyData:
Load
Date
,Day(Date) as DayNum
,MonthName(Date) as Monthname
,Dual(Text(Date),Day(Date)) as DayText
,ceil(Rand()*100) as randomval
;
load date(today()-recno()) as Date
AutoGenerate(90);

 

 

Then in Chart use the Field DayText as dimension

example Measures:

CurrentMonth

sum({<Date={">=2022-10-01<=2022-10-30"}>}randomval)

PReviousMonth

sum({<Date={">=2022-09-01<=2022-09-31"}>}randomval)

 

Capture.PNG

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
BenjaminCoe1440
Contributor III
Contributor III
Author

Yeah, that solution does exactly what I needed it to. Thanks very much for your help!