Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Vinni2000
Contributor III
Contributor III

Compare this year data vs last year data

 I have invoice date '20200831' format in purchase order data so now i want to compare thise year purchase amount vs last year purchase amount by months using bar chart .

4 Replies
Vinni2000
Contributor III
Contributor III
Author

IMG_20230526_192937.jpg

 i want my bar chart like this like i want to compare last 12 months data with previous 12 months data 

 

Kushal_Chawda

@Vinni2000  First create Calendar using InvoiceDate which contains Year & Month calculated using Invoice Date. Then create Bar chart with two dimension, 'Group' Month and 'Bars' as Year. Use below expression

Sum({<Year = {">=$(=max(Year)-1)"}>}Amount)

 

Screenshot 2023-05-30 at 11.44.23.png

Vinni2000
Contributor III
Contributor III
Author

Yeah I did the same and created month and year field from invoice create date using month() and year() then used same measures but i don't want that i want to compare this last 12 months means 2022 june to 2023 May with previous last 12 months means 2021 june to 2022 May

Kushal_Chawda

@Vinni2000  Considering you have calendar on required date. Create a Flag like below in Calendar

Calendar:
LOAD *,monthname(Date) as MonthYear,
     if(Date>= monthstart(addmonths(Today(),-11)) and Date <=Today(),'Last12Months',
     if(Date>= monthstart(addmonths(Today(),-23)) and Date<= monthend(addmonths(Today(),-12)) ,'PreviousLast12Months')) as Flag;

Month:
Load Distinct Month ,MonthYear
Resident Calendar
where Flag='Last12Months';

month_sort:
Load Month, RowNo() as Sort_month
Resident Month
Order by MonthYear;

Drop Table Month;

 

Create a bar chart with Dimension Month and below expression

Last12Month: Sum({<Flag={"Last12Months"}>}Sales)
Expression label: =text(monthname(min({<Flag={"Last12Months"}>}Date)))&'-'&text(monthname(max({<Flag={"Last12Months"}>}Date)))

PreviousLast12Month: Sum({<Flag={"PreviousLast12Months"}>}Sales)
Expression label: =text(monthname(min({<Flag={"PreviousLast12Months"}>}Date)))&'-'&text(monthname(max({<Flag={"PreviousLast12Months"}>}Date)))

 

Sort your Month Dimension by Expression =Sort_month

 Screenshot 2023-05-30 at 15.27.19.png