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: 
madhuqliklondon
Creator II
Creator II

Expressions help on WTD,MTD,YTD and LTD.

Hi I have created following on script level, Now I would like to create WTD,MTD,YTD and LTD sales and units sold.

Sales:

load

*,

MonthName([Created DateTime]) as MonthYear,

Year([Created DateTime]) as Year,

Month([Created DateTime]) as Month,

Week([Created DateTime]) as Week,

WeekEnd([Created DateTime]) as Weekend,

WeekStart([Created DateTime]) as Weekstart,

MonthStart([Created DateTime]) as Monthstart,

MonthEnd([Created DateTime]) as Monthend,

QuarterName([Created DateTime]) as QuarterName,

Date([Created DateTime])as DateNum

;

sql

SELECT  OrderNo

      , ln.[Item No_]

  ,itm.[EAN]

  ,ln.[Category]

      ,ln.[Total Price]

      ,ln.[Quantity]

  ,ord.[Created DateTime]

      ,ofr.[Brand]

      ,[RRP]

     FROM [Echo Trading$Order] ord

     inner join [Echo Trading$Order Line] ln

     on ord.No_=ln.[Order No_]

inner join [dbo].[Echo Trading$Offer] ofr

on ln.[Offer Id]=ofr.[Offer ID]

inner join

[dbo].[Echo Trading$Item] itm

on ln.[Item No_]=itm.[Item No_];

I would like to produce below table:

BrandItem NoWTD units WTD SalesMTD UnitsMTD SalesYTD UnitsYTD SalesLTD Units

LTD Sales

Do I have to create any variables for calculation?

Thank you in advance.

Madhu

4 Replies
Ponkaviyarasu
Partner - Contributor III
Partner - Contributor III

Hi Madhu,


Hope! Below post will give some idea for calculations.

https://community.qlik.com/docs/DOC-6163

Regards,

Kavi

madhuqliklondon
Creator II
Creator II
Author

Hi,

I have tried that ,but there is difference in sales WTD.

I have used sum(Total price) it gives £687 and when I use

Sum({<Year=, Month=, Quarter=, Week=, [Created DateTime]=, DateNum={">=$(=Num(WeekStart(Max(DateNum))))<=$(=Max(DateNum))"}>}[Total Price])  gives £571 exactly for that week and company started only last week. I would expect they should be same. And there are no sales for today.

madhuqliklondon
Creator II
Creator II
Author

Hi all,

Please check attached .qvw , WTD, MTD and YTD all showing same values. But data is there for 2 weeks. WTD and MTD must be different right. Please help.