1
votes

I have a shared dataset for a Mobile Report on SSRS 2016. The dataset sits on a SSAS data source, and has an MDX query to pull from the cube.

The primary key pulled back from the query is a date, and is formatted as such in SSAS; however when I use the dataset in Mobile Report Publisher it doesn't acknowledge it as a date datatype, it thinks it's a string. This means I can't use the dataset as a main series for a time chart, as it doesn't think there's anything formatted as a date.

The below is the section of MDX that I think is causing the issue.

SELECT
{
[Unresolved], [Assigned to Provider], [Unresolved past due date], [Other past due date], [Provider past due date], 
[Company past due date], [Provider PDD Daily Change], [Company PDD Daily Change], [Other PDD Daily Change], [Company pre due date], [Company PRDD Daily Change]
} ON COLUMNS,
NONEMPTY(
{
    [Date Snapshot].[Date].[Date]
}) ON ROWS
FROM [Source]
WHERE
( FILTER([Date Snapshot].[YQMD].[Date], [Date Snapshot].[YQMD].CURRENTMEMBER.MEMBER_KEY >= '2015-08-15') )
6

6 Answers

2
votes

Update: since SQL Server 2016 SP1 the workaround explained below is no longer necessary and dates should be properly recognized without doing anything special:

To try this new functionality out, create a simple MDX query using the Query Designer that includes a date field from your data model. When you consume that shared dataset with Mobile Report Publisher, it will properly recognize the date field from your query without an additional calculated measure being required.

The original text of the answer follows:

The reason as to why this happens is explained in the official Microsoft documentation:

The default return type for Analysis Services queries is a string. When you build a dataset in Reporting Services Report Builder, the string type is respected and gets saved to the server.

However, when the JSON table renderer processes the dataset, it reads the value of the column as a string and renders strings. Then when SQL Server Mobile Report Publisher fetches the table, it also only sees strings.

The official workaround is also explained there:

The workaround for this is to add a calculated member when you're creating a shared dataset in Report Builder.

An example of such a calculated member (taken from here):

cdate(format([Date].[Date].CURRENTMEMBER.MEMBER_VALUE, "yyyy-MM-dd"))

But this workaround (as pointed out by Victor_Rocca in a comment to the official Microsoft documentation) has a big problem:

The downside to this is that it will return all the dates that have been selected in your query, not just the ones that have a value associated with it in your cube (essentially removing the NON EMPTY behavior from the MDX query). When looking at a lot of records across time, this could significantly impact your report performance.

So I think there's a better workaround which is creating a calculated field in the dataset:

new dataset calculated field

with an expression such as this one (assuming the name of your field is 'Date' and that it returns unique names such as [Date Snapshot].[Date].[Date].&[2010-01-01T00:00:00] and [Date Snapshot].[Date].[Date].&[2010-12-31T00:00:00]:

=CDate(mid(Fields!Date("UniqueName"),33,10))

This way you don't have to manually edit your MDX and NON EMPTY behavior is preserved. This new field gets correctly identified as date datatype in Mobile Report Publisher:

date datatype

In any case, help is on the way, according to this post based on information obtained at last Pass Summit (October 2016), the following is being developed:

Better support for generated MDX. The current date workaround will no longer be needed and make everyone’s life easier.

1
votes

As far as I understand - MDX query language does not contain the data type "Date", hence it will be converted to "String".

IBM support - MDX Data types

Wikipedia - MDX Data types

1
votes

I had the same problem. You can go around this by creating a Member on the MDX query level using VBA functions:

WITH MEMBER [Date] AS Cdate([Date Snapshot].[Date].CURRENTMEMBER.Name)

SELECT ...

Your snapshot date needs to have one of the suggested formats. If it does cdate() function should do the trick. SSRS Mobile Publisher will recognize it as a date instead of string.

0
votes

I've encountered this before and in the tablix cell where I use one of these dates I used the following expression:

=format(cdate(Fields!Calendar_Day.Value),"dd MMM yy")
0
votes

I ended up wrapping the MDX in a T-SQL query, using OPENQUERY. This is clunky as hell, especially when I needed to pass a parameter, but it allowed me to explicitly convert the result set to whatever datatype I wanted. Urgh.

0
votes

The only way I managed to get MRP to recognize my date as a real date to filter trough time navigator was adding a calculated measure based on the MemberValue of the Date Dimension.

E.g.:

WITH MEMBER [Measures].[Date2] AS ([_Reference Period].[Date].CurrentMember.MemberValue) 

And after that, adding the field [Measures].[Date2] to the measures of the query:

SELECT NON EMPTY { [Measures].[Date2] } ON COLUMNS, NON EMPTY { ([_ReferencePeriod].[Date].[Date].ALLMEMBERS * [Companies].[Company].[Company].ALLMEMBERS * [Contract].[Type].[Type].ALLMEMBERS * [Employee].[Gender].[Gender].ALLMEMBERS * [Situation Type].[Situation Type].[Situation Type].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS FROM [SOURCE] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS