Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Running Division on First Date

Hello Experts, I was trying to create measure in DAX on the following data:  Table Name: Sample Product_id         date                  My_price         sales          other_price     Indexed oth...
  • v-xuding-msft's avatar
    v-xuding-msft
    6 years ago

    Hi Anonymous ,

     

    Please try like this:

     

    Create a month column:

    Month = MONTH('Table'[date])

    Create measures:

    Measure = 
    VAR first_date =
        MINX (
            FILTER (
                ALL ( 'Table' ),
                'Table'[date] <= MIN ( 'Table'[date] )
                    && 'Table'[Month] = MAX ( 'Table'[Month] )
            ),
            'Table'[date]
        )
    VAR first_other_price =
        CALCULATE (
            SUM ( 'Table'[other_price] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[Product_id], 'Table'[Month] ),
                'Table'[date] = first_date
            )
        )
    RETURN
        DIVIDE ( SUM ( 'Table'[other_price] ) * 100, first_other_price )
    

     

    AVG = 
    AVERAGEX(ALLEXCEPT('Table','Table'[date]),[Measure])