Forum Discussion

Amitkr174's avatar
Amitkr174
Helper III
3 years ago

Date DAX Calculation

Hi, tamerj1 

johnt75  parry2k Jihwan_Kim ThxAlot VahidDM 

 

 

I am trying to create a DAX for the below case:-

IF ( (I:O createddate) > Case Completion Date), then

    (I:O createddate) - Case Completion Date, 

     ELSE NULL)

I have created a DAX -  

IF([CreatedDate]>[Case_Comp_date],
           [CreatedDate]-[Case_Comp_date], BLANK())
Problem i am facing is when there are multiple dates with (i:o)Createddate>comp date for one DR ID. e.g.-For DR3622342, it should show blank from 2 row onwards.
 Please help on this.

 

 

21 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Amitkr174 Sorry, having trouble following, can you post sample data as text and expected output?
    Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

    Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi Amitkr174 

    I can tell that [CreatedDate] and [Case_Comp_date] are columns not measures and [Comp_Created_datediff] is a calculated column (summarized by sum) and not a measure as the total sums the individual values of the rows. Please confirm. I can also notice that both date columns are of text data type as they are alligned left. 
    However, what is confusing me is how the subtraction is actually calculating correct difference. Do you have other date columns of date data type?

    • Amitkr174's avatar
      Amitkr174
      Helper III

      Yes, columns  [CreatedDate] and [Case_Comp_date] are not measures. [Comp_Created_datediff] is a measure DAX is -

      IF([CreatedDate]>[Case_Comp_date],

                 [CreatedDate]-[Case_Comp_date], BLANK())
      Could you please let me know how to check for a date column, if the following date is greater or lesser from the previous date?

       

      • tamerj1's avatar
        tamerj1
        Community Champion

        Amitkr174 

        [Comp_Created_datediff] is most likely a calculated column. Please double check. The DAX that you have provided would result in an error if used in a measure. 
        It is important to have accurate information about the problem in order to be able to solve it.