I have one MDX query.
select [Measures].[Measure1] on columns,
[Locations].[Location].[LocationKey] on rows
from [MeasureLocation]
where
(
{[ServiceDate].[Date].[Date].[01-01-2013] : [ServiceDate].[Date].[Date].[01-01-2014]}
)
Here I gave date range between 01-01-2013 to 01-01-2014. So ideally SSAS should give record for this date range only. But the actual result is for 01-01-2013 to 31-01-2014. So, it's including whole month[31-01-2014].
Related
Below query is perfectly working and bringing rolling 12 months data for selected measure. Now how do I add one more measure to same MDX query so that query fetch rolling 12 months for 2 measures?
Thanks in advance for your help.
Working query with single measure
select
non empty({lastperiods(12,[Time].[By Fiscal Year].[Period].&[Jul-21])}) on columns,
[Customer].[CustomerName].[CustomerName].MEMBERS on rows
from(
select
([CustomerNamedSet]) on columns
from [CSIS]
where ({[Time].[By Fiscal Year].[Period].&[Jul-21]},
{[Measures].[measure1]})
)
enter image description here
Modified MDX query by adding one more measure in where clause (Not working)
select
non empty({lastperiods(12,[Time].[By Fiscal Year].[Period].&[Jul-21])}) on columns,
[Customer].[CustomerName].[CustomerName].MEMBERS on rows
from(
select
([customerNamedSet]) on columns
from [CSIS]
where ({[Time].[By Fiscal Year].[Period].&[Jul-21]},
{[Measures].[measure1],[Measures].[measure2]})
)
Expected results::
enter image description here
Am having 2001,2002 and 2003 years of data in the SSAS server.
Without using where clause and filters I need to get the aggregated data using the IIF function in the MDX query for a particular date range.
I have referred to many sites but I didn't find any solutions using date range in the IIF function.
These are the date values am having, so I need to get aggregated Sales Amount Quota values for a particular date range, for example, 01/07/2002 to 30/11/2002(It is dynamic). I need to use this date range in the IIF function.
My expected result is to be $24,381,800 for the given date range.
Can anyone please guide me to use the date range in the IIF function in the MDX query?
I am working pentaho dashboard trying to generate report to get transaction count per day between two date. i am beginner to mdx query below query shows only two date transaction count what i want is range between. i know it how to do it on simple query
SQL Working Query
SELECT
DATE(modified) AS trndate,
COUNT(id)
FROM
log.transaction
WHERE DATE(modified) BETWEEN DATE(${from_date}) AND DATE(${to_date})
GROUP BY
trndate
MDX Query which shows only two date transaction instead i want range between two date
WITH
SET [~ROWS] AS
{[created].[2014-10-01 12:01:53.507787], [created].[2014-10-01 20:34:14.410064]}
SELECT
NON EMPTY {[Measures].[id]} ON COLUMNS,
NON EMPTY [~ROWS] ON ROWS
FROM [transaction]
Usually you can use a colon to specify a range
WITH
SET [~ROWS] AS
{[created].[2014-10-01 12:01:53.507787]:[created].[2014-10-01 20:34:14.410064]}
SELECT
NON EMPTY {[Measures].[id]} ON COLUMNS,
NON EMPTY [~ROWS] ON ROWS
FROM [transaction]
This is similar to another question I made (MDX - Running Sum over months limited to an interval) but I feel that I was going off track there.
Let me start again.
I have a calculated measure
MEMBER [Measures].[m_active] AS ([Measures].[CardCount], [Operation].[Code].[ACTIVATION])
That I want to filter on a short interval (let's say from 10 January 2016 to 20 August 2017, those are parametrized)
and another calculated measure that i want to filter since the beginning of date dimension (1st January 2010) to the end of last filter (20 August 2017 in this case), this measure is running sum of all the precedent
MEMBER [Measures].[tot_active] AS (
SUM({[Calendar.YMD].[2010].Children}.Item(0):[Calendar.YMD].CurrentMember, ([Measures].[CardCount], [Operation].[Code].[ACTIVATION]))
On the columns I have this calculated dimensions and on the rows I have months (in the small interval range) and another dimension crossjoined
SELECT
{[Measures].[m_active], [Measures].[tot_attive]} ON COLUMNS,
NonEmptyCrossJoin(
{Descendants([Calendar.YMD].[2016].[Gennaio]:[Calendar.YMD].[2017].[Agosto], [Calendar.YMD].[Month])},
{Descendants([CardStatus.Description].[All CardStatus.Descriptions], [CardStatus.Description].[Description])}
) on ROWS
If I put a date range in the WHERE clause the first member is perfect but i ruin the second, how can I make the second member ignore the WHERE clause? Or is there another solution?
Without testing I'm a little bit unsure of the behaviour, but did you try moving the filter from a WHERE clause into a subselect?
Subselects are formed like this:
...
FROM (
SELECT
<date range for filter> ON 0
FROM cubeName
)
I have a dimension [Date].[Last Met].
I need to pull out values which are more than 90 days from current date using MDX.
Please suggest the best way.
You can filter like this:
FILTER
(
[Date].[Last Met].MEMBERS,
Datediff("d",[Date].[Last Met].CurrentMember.Name, Format(Now(),'yyyyMMdd') <=90
)
A much more elegant option would be to create a calculated column in DSV called RollingLast90Days, and using SQL datediff logic to assign it 1/0. Once in place, you would need to just have a slicer :
...WHERE ([Time].[[RollingLast90Days].&[1])
Above is based on asumption you would process cube daily. If not apply the same logic in a calculated measure.
IIF(
Datediff("d",[Date].[Last Met].CurrentMember.Name, Format(Now(),'yyyyMMdd') <=90,
1,
null)
and then using this slicer on HAVING or in WHERE clause.