Forum Discussion

Junkay's avatar
Junkay
Regular Visitor
2 years ago
Solved

Time intelligence function returning wrong month

Hi All,   I'm tring to extract month from date column in the table shown below. But I'm getting wrong month. For the month of July, Jan is returned in the month column. Please what could be the iss...
  • OwenAuger's avatar
    2 years ago

    Hi Junkay 

    Change line 3 of the code to

     

    "Month", FORMAT ( [DATE], "mmm" ),

     

  • OwenAuger's avatar
    OwenAuger
    2 years ago

    Hi again Junkay 

    The ENDOFMONTH function will produce the expected result as long as the column reference provided as an argument is for a column which contains complete calendar months. If any dates are missing, this function treats the last available date in a given calendar month as the last day of the month. The tutorial you were using may have already had a table containing complete months.

     

    For this reason, I would generally not advise using ENDOFMONTH to return a scalar end-of-month value. EOMONTH is the best function for this.

     

    ENDOFMONTH is typically used within CALCULATE to modify a date filter by shifting it to the last day of the last visible month. ENDOFMONTH returns a 1x1 table which retains lineage to the column reference passed as its argument.

     

    On to your latest question, to return an end-of-quarter date, I would advise using EOMONTH again.

    For standard calendar quarters (Jan-Mar, Apr-Jun etc), an expression like this should work:

     

    EOMONTH ( [Date], MOD ( - MONTH ( [Date] ), 3 ) )

     

  • Junkay's avatar
    Junkay
    2 years ago

    Hi Owen,

     

    You are a genius. Thank you so much for the support.

     

    I wish I could be this proficient.

     

    Thanks a million times.