0
votes

Is it possible to create a calculated measure that calculates differently on the basis by the date chosen dynamically from the related time table "DimDate"?

So i want a static date "2017-01-01" that if less computes [amount]+[count] and if greater [amount2]+[count2].

E.g

if([Date]<"2017-01-01",[Amount]+[Count],[Amount2]+[Count2])

Background:

The measures Amount/2 and Count/2 is both calculated measures that is a sum of respective columns found in the fact table. The time table DimDate is a normal time table where [Date] column yyyy-mm-dd is joined by [Reportdate] column found in the fact table.

2

2 Answers

0
votes

I have a solution if the Key of your Date members is an integer e.g. for the member 2017-01-01 in your Date dimension, it has a key of 20170101.

Then the following example using Adventure Works can be amended very easily to suit your needs:

WITH MEMBER [Measures].[SomeMeasure] AS
    IIF(STRTOVALUE([Date].[Date].CURRENTMEMBER.PROPERTIES("KEY")) < 20050714, "Before", "After")
SELECT
    [Measures].[SomeMeasure] ON COLUMNS
,   [Date].[Date].[Date] ON ROWS
FROM
    [Adventure Works]
0
votes

DimDate:

date
01/11/2016
01/12/2016
01/01/2017
01/02/2017
01/03/2017

Measures:

Amount = 1
Count = 2
Amount2 = 3
Count2 = 4
Measure = IF(FIRSTNONBLANK(dimDate[date],true)<DATEVALUE("01/01/2017"),
    [Amount]+[Count],[Amount2]+[Count2])

enter image description here

enter image description here