Qlikview - text object num - qlikview

I have text object with text
=num( Sum( Aggr( Quantity*Price, PostingYear1, LineNumber )), '#,##0.0')
and I have year 2015 and 2016.
When save this expresions i got sum of bouth year 2015 and 2016. how to get only 2015?

use set analysis:
=num( Sum({<Year = {2015}>} Aggr( Quantity*Price, PostingYear1, LineNumber )), '#,##0.0')

Related

Named Set MDX Error

I'm having this error after creating a named set in SSAS to retrieve the last 10 weeks from the first day of current week. the expression I used is :
strtoset(
"LASTPERIODS(
10
,[AxeTemps].[Semaine].&["+Format(NOW()-WEEKDAY(NOW(),2),'yyyyMMdd')+"]")
My date hierarchy has the following members structure :
[AxeTemps].[Semaine].&[20000101].
I can't get this work, any idea ?
You have convert the a member first, then you can pass it to the LastPeriods():
LastPeriods(
10,
StrToMember("[AxeTemps].[Semaine].&[" + Format(NOW()-WEEKDAY(NOW(),2),'yyyyMMdd') + "]")
)

Getting incorrect results in Qlikview Analyser

I need help with a report I am trying to create with Olikview Analyser. The problem is I keep getting incorrect results. I think it may be related to the metrics being slightly wrong. The data source definitely has the correct figures, but when I am trying to run select queries results are not right. Here is an example. To see sales for Last Week Last Year (sales for Last week 2015)
Currently the Analyser code is as follows:
sum({$<DATE_WEEK={$(LastWeekLY)}, DATE_FYEAR {$(LastWeekYearLY)}>}POS_SALES_VALUE_GROSS)
+
sum({$<DATE_WEEK={$(LastWeekLY)}, DATE_FYEAR {$(LastWeekYearLY)}>}CS_SALES_VALUE_GROSS)
+
sum({$<DATE_WEEK={$(LastWeekLY)}, DATE_FYEAR={$(LastWeekYearLY)}>}CO_ITEM_TOTAL)
However, the figures I get are far too high. Are there any obvious errors in the code?
Thanks in advance for your help
Try
sum({$<DATE_WEEK={'$(LastWeekLY)'}, DATE_FYEAR={'$(LastWeekYearLY)'}>} numsum(POS_SALES_VALUE_GROSS,CS_SALES_VALUE_GROSS,CO_ITEM_TOTAL))
sometimes the weeks/years are stored as text and not numbers..so this will fix this issue.
If this does not work then you have a problem in your variables.
Please try
sum( {$< DATE_WEEK = {$(#LastWeekLY)} , DATE_FYEAR = {$(#LastWeekYearLY)} >} POS_SALES_VALUE_GROSS ))+
sum( {$< DATE_WEEK = {$(#LastWeekLY)} , DATE_FYEAR = {$(#LastWeekYearLY)} >} CS_SALES_VALUE_GROSS ))+
sum( {$< DATE_WEEK = {$(#LastWeekLY)} , DATE_FYEAR = {$(#LastWeekYearLY)} >} CO_ITEM_TOTAL))

Mdx Query Show Year Level Data for all years except This Year

SELECT
NON EMPTY
{[Measures].[AMOUNTCUR]} ON 0
,NON EMPTY
{
NULL : [PRX_UE_DATE].[Calender].[Year].&[2015]
,[PRX_UE_DATE].[Calender].[Year].&[2017]
,Descendants
(
[PRX_UE_DATE].[Calender].[Year].&[2016]
,[PRX_UE_DATE].[Calender].[Month]
)
} ON 1
FROM [PRX_SalesDataModel];
I have a query like above. It's working It returns 2016 on month based others years are year based.
Now I have to add more dimensions on this mdx but when i try it to like
SELECT
NON EMPTY
{[Measures].[AMOUNTCUR]} ON 0
,NON EMPTY
{
NULL : [PRX_UE_DATE].[Calender].[Year].&[2015]
,[PRX_UE_DATE].[Calender].[Year].&[2017]
,
Descendants
(
[PRX_UE_DATE].[Calender].[Year].&[2016]
,[PRX_UE_DATE].[Calender].[Month]
)
*
[PRX UE CLIENT].[SEGMENTID].ALLMEMBERS
} ON 1
FROM [PRX_SalesDataModel];
I get error Members, tuples or sets must use the same hierarchies in the function.
You just need to keep all the date dimension stuff in set braces {...}:
SELECT
NON EMPTY
{[Measures].[AMOUNTCUR]} ON 0
,NON EMPTY
{
NULL : [PRX_UE_DATE].[Calender].[Year].&[2015]
,[PRX_UE_DATE].[Calender].[Year].&[2017]
,
Descendants
(
[PRX_UE_DATE].[Calender].[Year].&[2016]
,[PRX_UE_DATE].[Calender].[Month]
)
}
* [PRX UE CLIENT].[SEGMENTID].ALLMEMBERS
ON 1
FROM [PRX_SalesDataModel];
You could even make it maybe more readable by moving the date stuff into a named set via a WITH clause:
WITH SET [DatesSet] AS
{
NULL : [PRX_UE_DATE].[Calender].[Year].&[2015]
,[PRX_UE_DATE].[Calender].[Year].&[2017]
,
Descendants
(
[PRX_UE_DATE].[Calender].[Year].&[2016]
,[PRX_UE_DATE].[Calender].[Month]
)
}
SELECT
NON EMPTY
{[Measures].[AMOUNTCUR]} ON 0
,NON EMPTY
[DatesSet]
* [PRX UE CLIENT].[SEGMENTID].ALLMEMBERS
ON 1
FROM [PRX_SalesDataModel];
You've got your answer from #whytheq on why the error cropped up. There is just one part which I felt is not handled yet. You are building the set of years by hand. Instead of that, it can be made dynamic like below -
with set AllYearsExceptCurrent as
filter(
[PRX_UE_DATE].[Calender].[Year].members as yr,
yr.current.item(0).member_value <> Format(Now(), "yyyy")
)

Why won't my sql command work on asp when it showed the correct result in ACCESS?

Now that I have help from this forum's,I have the sql command which can produce the correct result in ACCESS. However when I brought that to use in ASP the error said like this..
Microsoft JET Database Engine error '80040e14'
The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
what did I do wrong ? my asp code is ….
Dim rsBill
set rsBill = Server.CreateObject("ADODB.Recordset")
rsBill.ActiveConnection = Conn_string<br>
rsBill.Source ="select sum(tbt.bill_total) as bill_total ,iif(sum_vat_total is null, 0, sum_vat_total) as vat_total, iif(sum_vat_total is null, 0, sum_vat_total) + sum(bill_total) as sum_of_all, month(showndate) as month from tbl_bill_total tbt left join (select sum(vat_total) as sum_vat_total , month(showndate) as month from tbl_vat_bill_total where if_paid = true and year(showndate) = 2013 group by month(showndate)) tvt on tvt.month = month(tbt.showndate) where year(showndate) = 2013 group by month(showndate) , sum_vat_total"
rsBill.CursorType = 0
rsBill.CursorLocation = 3
rsBill.LockType = 3
rsBill.Open()
rsBill.PageSize = 20
I've tried for several days to find out what's wrong but still couldn't get it.
The SELECT statement includes month as an alias (in two places) ...
month(showndate) as month
Since there is a function with the same name, month is likely the reserved word the db engine is complaining about. If you want to keep that alias, enclose it in square brackets.
month(showndate) as [month]
You reported the query ran without error in an Access session. In that situation, the query is run from DAO. But it fails when run from ADO because ADO seems to be less forgiving about reserved words.

Getting dates outside of range I specify

I have a report that I am trying to fix with SSRS because when you run it for a specific range say one month of year. It will give you all previous years too even if its outside of parameter bounds.
SELECT
to_char(app.RECEIVED_DATE, 'mm-dd-yyyy') AS received_date
, res.RESIDENCETYPE_NAME || ' - ' || act.ACTIONTYPE_NAME type
, sts.APPLSTSTYPE_NAME AS Status
, COUNT(*) AS Total_Count
FROM
ODILIC_ADMIN.LICENSEAPPL app
, ODILIC_ADMIN.LICENSEDEF def
, ODILIC_ADMIN.ACTIONTYPE act
, ODILIC_ADMIN.APPLSOURCE src
, ODILIC_ADMIN.RESIDENCETYPE res
, ODILIC_ADMIN.LICENSETYPE ltype
, ODILIC_ADMIN.LICENSINGENTITYTYPE etype
, ODILIC_ADMIN.APPLSTSTYPE sts
WHERE app.LICENSEDEF_ID = def.LICENSEDEF_ID
AND app.ACTIONTYPE_ID = act.ACTIONTYPE_ID
AND app.APPLSOURCE_ID = src.APPLSOURCE_ID
AND def.RESIDENCETYPE_ID = res.RESIDENCETYPE_ID
AND def.LICENSETYPE_ID = ltype.LICENSETYPE_ID
AND def.LICENSINGENTITYTYPE_ID = etype.LICENSINGENTITYTYPE_ID
AND app.APPLSTSTYPE_ID = sts.APPLSTSTYPE_ID
AND (app.RECEIVED_DATE BETWEEN '01-JUN-2013' AND '30-JUN-2013')
and sts.APPLSTSTYPE_NAME in ('Completed')
GROUP BY
to_char(app.RECEIVED_DATE, 'mm-dd-yyyy')
, res.RESIDENCETYPE_NAME
, act.ACTIONTYPE_NAME
, sts.APPLSTSTYPE_NAME
order by 1
So this query will filter between jun 1 and jun 30 of this year. When I run it in plsql it works fine but as soon as I put it into ssrs it will give me june counts for 2012 and 2011
On this line: AND (app.RECEIVED_DATE BETWEEN '01-JUN-2013' AND '30-JUN-2013')
I would be setting up parameters in SSRS directly to handle this as this may handle the translation of types more expicitly to specify (DateTime) as the parameter type and then changing the line to be:
AND (app.RECEIVED_DATE BETWEEN #Start AND #End)
I have not played with plsql with SSRS but I have seen translation of types problems with dealing with WCF and other channels. My usual attempt is to first specify a parameter to pass into the query execution and see if there is still an issue.