Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

TOTALYTD Issue with 99991231 date in Date Dimension

Has anyone else experienced an issue when trying to use TOTALYTD function when they have the date 9999-12-31 in their Date dimension?

 

We have a Fact table where workers are set targets on a monthly basis, i wanted to create a YTD measure for this (pretty simple so i thought!!)  However i kept getting the following error.

 

Error Message:
MdxScript(Model) (4, 46) Calculation error in measure 'Fact WorkerTargets'[Target Fees YTD]: An invalid numeric representation of a date value was encountered.

 

 

The fact table has a TargetDateKey field (date key is an integer in the format of  YYYYMMDD) linked to the date dimension table  via simialr key on Date Dimension Table ([DateKey]), the date dimension has a [Date] field which has the date stored in a proper Date format and it is set as a Date datatype in the model.

 

My Targets YTD  Measure on my Fact Table looks like this

 

Target Fees YTD = TOTALYTD(SUM('Fact WorkerTargets'[Target Fees]),'TargetDate'[Date],ALL('TargetDate'),"30 Apr")

 

However if i dont exclude the date 99991231 from the datetable then i get the above error and the graphic doesn't display

Exclude the date and everything works ok.

 

Any ideas?

 

Thanks

5 REPLIES 5
mark_i_roberts
New Member

had similar issue.  Rather than removing the date Dec 31st 9999 which is valid and often used date from the date table.

Try:
create a new column in the date table called say 'DateExcl9999' which is defined as
= if( [Date Key] < 90000101,[Date])


[Date Key] here is an integer yyyymmdd so it is happy to consider values such as Jan 1st 9000 or 999991231 as it doesn't have to consider these valid dates.


so [DateExcl9999] will be blank/null for all dates in Year 9999.  Redefine your Target Fees YTD  function using this new date.  So something like:

Target Fees YTD := TOTALYTD(
    SUM('Fact WorkerTargets'[Target Fees]),'
     TargetDate'[DateExcl9999],
     ALL('TargetDate'),
     "30 Apr")

v-yuezhe-msft
Employee
Employee

@Anonymous,

I am afraid that you would need to exclude the 9999/12/31 date from the date table.

Based on my test, when we don’t exclude 9999/12/31 from date dimension table, same error will occur even we use DATSYTD function to calculate the measure.

Target Fees YTD = CALCULATE (SUM('Fact WorkerTargets'[Target Fees]), DATEDYTD('TargetDate'[Date],"30 Apr"),FILTER('TargetDate', 'TargetDate'[DateKey]<99991231))
1.JPG


Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-yuezhe-msft

 

so is this a Power BI issue , or a DAX engine issue?

 

9999-12-31 is a common unknown end date sceanrio in DWHing, how are other people handling this? seems daft you have to exclude it?!?

 

thanks

@Anonymous,

Based on my test, we have to exclude the date from Date table. 

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

I've also tried rewriting the query filtering out the date  rather than removing it from the table explicitly however i now get the error

 

Capture1.PNG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.