Forum Discussion

PBI5851's avatar
PBI5851
Helper V
5 years ago
Solved

If and DateAdd not working

Hi,  Please advise on what is wrong in this formula. I am trying to create a column to add the dates based on the User field.   ExpectDate = If (Primary[User1] = "Steve", dateadd(Primary[Hiredate]...
  • v-robertq-msft's avatar
    5 years ago

    Hi, PBI5851 

    According to your description, I think the reason why the value of your calculated column displayed blank is the Dateadd() function returns a table containing a single column of date values. If you want to calculate for every column in the table, you can try this:

    This is my test data:

    ExpectDate =
    
    SWITCH(
    
        TRUE(),
    
        'Primary'[User1]="Steve",'Primary'[Hiredate]+10,
    
        'Primary'[User1]="John",'Primary'[Hiredate]+20,
    
        0)

    Then change the column tyoe to “Date”, and you can get what you want, like this:

     

    You can download my test pbix file here

     

    More info about Dateadd() function

     

    If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

    How to Get Your Question Answered Quickly 

     

    Best Regards,

    Community Support Team _Robert Qin

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.