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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
LC_RepAC
New Member

Calculated column (date) not returning expected results

Hi, I have a table pulling [PrimaryKey], [Application], [Start Date] and [End Date] values from an existing table.

The rest of the new table is mostly made of calculated columns.

 

The calculated columns that are causing me grief are as follow:

CheckDate1 = IF(MultipleEndDateTable[Combo]="1Y", BLANK(),DATEADD(MultipleEndDateTable[Start Date].[Date],1,YEAR))
CheckDate2 = IF(MultipleEndDateTable[Combo]="2Y", BLANK(),DATEADD(MultipleEndDateTable[CheckDate1].[Date],1,YEAR))
CheckDate3 = IF(MultipleEndDateTable[Combo]="3Y", BLANK(),DATEADD(MultipleEndDateTable[CheckDate2].[Date],1,YEAR))
CheckDate4 = IF(MultipleEndDateTable[Combo]="4Y", BLANK(),DATEADD(MultipleEndDateTable[CheckDate3].[Date],1,YEAR))
etc...
 
The point is to only return a new Checkpoint Date if:
1) the Combo counter differs from a specific value
AND
2) the previous calculated date in the series is not blank
 
As you can see from the screenshot:
CheckDate1 returns the correct values (even on a bigger data sample)
CheckDate2 doesn't always return the expected values (see cell in red, which should contain a value)
Ditto for CheckDate3, CheckDate4, etc...
 
Cells in red => missing value
Cells in green => correct
 

LC_RepAC_0-1617716341685.png

 

I edited the formulae to something much simpler, e.g.

 

CheckDate2 = IF(MultipleEndDateTable[Combo]="1Y", BLANK(), "Checkpoint Date")

 

This returned accurate results, so it's either something to do with the DATEADD function or the fact that calculations can't be based on other calculations because you can't predict which calculations will take place first.

 

I guess I should be using something else to get to the desired output. That, or I'm failing to spot an obvious mistake in my formula...

 

Thanks in advance to whoever can help me with this 🙂

LC

2 REPLIES 2
Anonymous
Not applicable

@LC_RepAC 

 

Please read the documentation of the function you're trying to use: https://dax.guide/DATEADD.

amitchandak
Super User
Super User

@LC_RepAC , Dateadd need the continuous date , in place of that use date like

 

example

 

CheckDate1 =
var _1 = MultipleEndDateTable[Start Date].[Date]
return
IF(MultipleEndDateTable[Combo]="1Y", BLANK(),date(year(_1) +1, month(_1), day(_1)))

 

refer:

https://www.youtube.com/watch?v=YWo-ZpKM6gU

https://www.youtube.com/watch?v=9qiRivlBv8w

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors