Bart
Bart

Reputation: 43

Argument type mismatch error using the DaysBetween() function in a calculated measure

I am using icCube 5.0.1 and in the process of upgrading to 5.1.

I am attempting to use the Builder to create a Calculated Measure using the following formula: DaysBetween([LastReportingDate], Today())

[Measure].[LastReportingDate] is a measure within the cube with a Date data type.

The purpose is to create a calculated measure that provides the number of days between [Measure].[LastReportingDate] and today and use it within a report.

When I add the new calculated measure to a report table, the column cells are filled with 'error', and when I hover over a cell the error message reads: DaysBetween(): argument (0) type mismatch: expected 'date' got: 'measure'.

Manual reference: http://www.iccube.com/support/documentation/mdx/DaysBetween.php

Any hints? Many thanks!

Upvotes: 1

Views: 154

Answers (3)

Bart
Bart

Reputation: 43

After more research and experimentation, I solved the problem as follows:

  • I used the following formula for the calculated variable: Today()-[LastReportingDate]
  • I used the following Cell Properties entry: Format_String = '#,##0' Note that without using the the Format_String, the report displayed a date.

Thanks to all for your assistance.

Upvotes: 0

Marc Polizzi
Marc Polizzi

Reputation: 9375

Assuming the [LastReportingDate] is a time dimension (i.e., with the member key being an actual date (and not a string representing a date) ) you can do the following:

DaysBetween( [LastReportingDate].KEY, Today() )

In case [LastReportingDate] is a [Measures] of type Date, you can use the Value() function to get its actual date as following:

DaysBetween( [Measures].[LastReportingDate].Value, Today() )

Note: If the key is a string, please edit your question with its pattern description.

Upvotes: 2

whytheq
whytheq

Reputation: 35557

Can you use the memberValue property:

DaysBetween([LastReportingDate].MemberValue, Today())

(p.s. I use Pyramid not icCube so this may be way of the mark!)

Upvotes: 2

Related Questions