Forum Discussion

shyamji's avatar
shyamji
Helper I
6 years ago
Solved

Last 6 month data with filter

Hi,

i want last 6 months data but filter each month data like below DAX

CreatedTicket(6Months) =
CALCULATE (
COUNT('TicketsDetailMonthly'[TicketId]),FILTER('TicketsDetailMonthly', MONTH('TicketsDetailMonthly'[CreatedDate])= MONTH(MAX('Date'[Date])) && YEAR('TicketsDetailMonthly'[CreatedDate])= YEAR(MAX('Date'[Date]))),
DATESINPERIOD ('Date'[Date], MAX('Date'[Date]), -6, MONTH ))
 
but this one is filtering only selected month and year data rather than filtering each month month in last 6 months.
Please help.
Thanks
  • Hi shyamji ,

     

    I have created a sample for your reference.

     

    Measure = 
    VAR sel =
        MAX ( 'date'[Date] )
    VAR prese =
        EDATE ( sel, -6 )
    RETURN
        IF (
            MAX ( 'Table (2)'[date] ) >= prese
                && MAX ( 'Table (2)'[date] ) <= sel,
            CALCULATE ( SUM ( 'Table (2)'[value] ) ),
            BLANK ()
        )
    

     

     

    Pbix as attached.

     

2 Replies

  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi shyamji ,

     

    I have created a sample for your reference.

     

    Measure = 
    VAR sel =
        MAX ( 'date'[Date] )
    VAR prese =
        EDATE ( sel, -6 )
    RETURN
        IF (
            MAX ( 'Table (2)'[date] ) >= prese
                && MAX ( 'Table (2)'[date] ) <= sel,
            CALCULATE ( SUM ( 'Table (2)'[value] ) ),
            BLANK ()
        )
    

     

     

    Pbix as attached.

     

  • Mariusz's avatar
    Mariusz
    Community Champion

    Hi shyamji 

     

    Can you create a data sample + expected result?

     

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    LinkedIn