Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I would like to perform the following simple SQL or condition within Qlik:
SELECT Count(1)
FROM FactTable
WHERE (SaleDate BETWEEN 20160501 AND 20160531
OR [QuoteDate] BETWEEN 20160501 AND 20160531)
i.e simple or condition. I am using the inbuilt calendar liked to SaleDate so this calls for set Analysis. However I am missing a couple of records due to the "or" statement failing:
RowNo | QuoteDate | SaleDate |
---|---|---|
1 | 20160430 | 20160507 |
2 | 20160513 | 20160609 |
3 | 20160527 | 20160621 |
If I base it upon my logic on the Quote date (equal to MAY 2016) I miss the first row which should be included as the sale date is in MAY. If I base my logic on the Sale date I miss rows 2 and 3 which should be included as the quote took place in MAY hence the OR.
What I have in Qlikview is:
=Count ({$< YearMonth = {"$(=Date(QuoteDate,'YYYY-MM'))"},Year=,FiscalYear=,Month=,WeekDay=,Quarter= > +
< YearMonth = {"$(=Date(SaleDate,'YYYY-MM' ))"},Year=,FiscalYear=,Month=,WeekDay=,Quarter=>} IsSale )
YearMonth is 2016-05 created from the selected year and month. No other date selections are made or available. By the way I have converted the dates to proper dates in the loads script. Sumof ISsale are Sales, Count of IsSale are quotes.
Simply stated what I want is to include all quotes where the QuoteDate OR the saleDate match the selected (YearMonth e.g. ‘2016-05’) ignoring all date related sections so I am left with the full set of date related data to make the comparison .
Many Thanks in Advance & Kind Regards
Mike
Ruben -
I don't understand what the -* is for on the end of a couple of the statements just before the }
=Count({<QuoteDate={"$(=Date(Max(SaleDate),'YYYY-MM'))-*"},
SaleFiscalYear=,SaleWeekDay=,SaleQuarter=, SaleMonth= > +
<SaleDate={"$(=Date(Max(SaleDate),'YYYY-MM'))-*"}, SaleFiscalYear=,SaleWeekDay=,SaleQuarter=, SaleMonth= >} IsSale)
Can you explain what that is doing?
Hi Mary, that's the string used to search, and the '*' is a wildcard to look for all combitanion of characters, ie: using "2018-10-*", filters dates starting by '2018-10-', wich will be all dates for october 2018.
I am comparing this way. Am I doing wrong?
Count({<[FIELD_NAME_1] = {'VALUE1'}, [DATE_FILED_1] -= {'[DATE_FILED_1] <= [DATE_FILED_12])'}>} COUNT_FIElD_NAME)