Date Range in Where clause - ssas

I have ssas DB with two cubes, they share the date dimension.
My query shows users on the dimension and visit as a measure. In the where clause I have range of dates.
I have this strange behavior that after a FULL cube process I don't see any data when applying the range. I'm sure that I have data for the range because when I filter each day desperately I can see data.
Another weird scenario is that if the date is on the dimension I can see data.
The thing that solve it is when process DATA the cubes.
This my query:
select non empty [Users].[User].[User] columns,
{[Measures].[Visits]} on rows
from [System Visit] where
([Dim_Date].[Georgian Calendar].[Date ID].&[20150125]:[Dim_Date].[Georgian Calendar].[Date ID].&[20150202])
Any thought what can be the issue?
Thanks

If you dont have the borders defined then your filter will work like NULL:a, b:NULL, or NULL:NULL depending on availability of border in the cube.
In this case, I would suggest all possible dates into your [Dim_Date].[Date ID] attribute.

Related

How to show dimension members for which there are no values in fact in SSAS Multi-Dimensional?

I have two tables in my Ticket Management Application, "ExpositionPeriods" and "OrganisedVisits".
ExpositionPeriods - Defines the periods for which tickets can be purchased.
OrganisedVisits - Stores the tickets purchased information.
In the example below, we have 5 periods available, and tickets have been purchased for 2 of the periods.
The customer wants a report which shows "Number of visitors against each available period". That means if, for any period which doesn't have a visitor, the report should show "0" for that period. Something like this.
So far so good. Since the production database is humongous (~500 GB), it is not advisable to report on this database directly. Things turn to be challenging when I create an OLAP cube out of this schema and try to achieve the same report functionality in the cube. It seems the cube actually performs an action similar to SQL INNER JOIN as opposed to a LEFT OUTER JOIN and hence I do not see those Periods for which there are no tickets sold.
Is this how SSAS actually behaves? Am I missing out any particular setting that will indicate the SSAS engine to process the cube in a different manner so as to include the missing periods as well? Please note, end customers don't have access to MDX/DAX scripts, they can only use the cube by drag-drop measure and dimensions like in Excel pivot table.
In your image the browser is carrying out a non empty on rows on the date dimension. If you want to show the dates with no visitors then select the option to show empty cells.
You can define such scope in "calculations" as
SCOPE
([Measures].[Visitors]);
THIS=IIF(ISEMPTY([Measures].[Visitors]),0,[Measures].[Visitors]);
END SCOPE;
So you have zeros instead of nulls and side effect. You or customer can't hide empty cells, cause now it's not empty enough.

SSAS - No of Working Days as Named Calculation

I am new to SSAS. I have a requirement, I need to calculate no of working days between user selected date range (either in Excel or SSRS or PowerBI). I found the MDX query, I need assistance with create a named calculation with MDX expression.
Date Dimension (Filtered):
MDX:
WITH MEMBER Measures.WorkingDays AS
COUNT
(
exists( EXISTING {[Dim Date].[Date].[Date].members}
, [Dim Date].[Is Weekday].&[1] )
)
Select {Measures.WorkingDays} on 0 ,
[Dim Date].[Month].[Month] on 1
from [Project Cube]
where ([Dim Date].[Date].&[2018-01-01T00:00:00]:[Dim Date].[Date].&[2018-04-25T00:00:00])
I need to add this named column on Fact table as measurement. I am having trouble with the below items:
Creating named query with MDX expression mentioned.
Adding a [Number of Working Days] as measure in Fact table.
Please correct me, If I am doing it in wrong way. My requirement is I need a [NoOfWorkingDays] as measure in fact table, so that I can use SSAS aggregate to use it as input on other measure, such as ([utilization%] = ([ActualDaysWorked] / [NoofWorkingDays]).
Note that, I can do analysis with the given MDX, but I need to deploy it with precalculated values in cube, so that end user can directly use the cube.
Kindly let me know, if more details required, Thank you.
Welcome to SSAS and MDX. Now to the answer.
I need to add this named column on Fact table as measurement. I am
having trouble with the below items:
Creating named query with MDX expression mentioned. Adding a [Number
of Working Days] as measure in Fact table.
You dont need to add it to the Fact table at all. Open your SSAS project, in your object explorer double click your cube. Now on the top left hand you will see a CALCULATIONS tab. In the CALCULATION tab, Click new calculated member, the icon has a calculator on it.
Please correct me, If I am doing it in wrong way. My requirement is I
need a [NoOfWorkingDays] as measure in fact table, so that I can use
SSAS aggregate to use it as input on other measure, such as
([utilization%] = ([ActualDaysWorked] / [NoofWorkingDays]).
If I remember correctly, the calculated members will not be added into the Aggregations, however the underlying measures would be. Secondly if you are wondering that you can use your calculated Measure in another calculated measure. The answer is yes you can use it in another calculated measure. So this is totally possible
> ([utilization%] = ([ActualDaysWorked] / [NoofWorkingDays])
where [utilization%] and [NoofWorkingDays] are calculated measures.

How to deal with rows in fact table that don't have matching value in date dimension, ssas cube?

I a new to this site and to SSAS in general. I am currently doing some "on the job training" trying to put together an SSAS cube and I am experiencing some problems.
When I try to process the Cube it fails. This happens due to the fact that the Fact table used for the cube contains some 13 rows that have dates that are outside of the range of the Date dimension that I am using.
I am not sure what I should do to get around/fix this.
Exclude the rows?
Change the dimension?
I have tried to find an answer to this on my own, but it seems that my phrasing of the issue/problem has so far stopped me from finding relevant information.
Any advice or ideas would be greatly appreciated!
/Chriss

How to sort this by month in MDX?

I have never wrote a MDX line by myself, I have been using pentaho and a CDE Wizard to create some charts and it generates this code:
select NON EMPTY({Descendants([NOM_MES].[All NOM_MESs] ,[NOM_MES].[NOM_MES])}) on ROWS,
NON EMPTY({[Measures].[TOTAL]}) on Columns
from [museos_md]
where (${select_museoParameter})
I want to sort that result by a right mohth sequence, because I am getting the months in an alphabetical order. I also have a COD_MES measure that is the correct order of the months, I mean: NOM_MES->COD_MES, January->01, February->02 (coul it be useful?)
The quick solution would be to use
Order(Descendants([NOM_MES].[All NOM_MESs] ,[NOM_MES].[NOM_MES]), [Measures].[COD_MES], DESC)
in MDX.
The correct approach would be to do the sorting in the cube design. I am not sure about Pentaho, but in Analysis Services you can configure the month attribute to e. g. use the month code as key, and the month name as name column shown to users, and do the sorting based on the key. This also affects the display of the attribute as shown to the users, where alphabetically sorted month names are a bit confusing.

MDX Measure Filtering

I am building a Mondrian Cube that shows information for a large range of dates. One of the measures for this cube is an average of a percentage value. Because some of the items in the cube should not make up the final average, I need to know how to filter them out based off this measure and only for this calculated member.
Found the solution to this thanks to the group over at the Pentaho forum:
http://forums.pentaho.org/showthread.php?t=75742