Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Aggregation Problem regarding finding average for repeated values

Im facing an issue regarding aggregation and Im doing average of a value. I have below values  and Im trying to find the average value but Im not able to get the values correctly. Any help will be gr...
  • v-yuta-msft's avatar
    6 years ago

    Anonymous ,

     

    Create measures using dax below:

     

    Average Length of Stay for Hotel = 
    AVERAGEX (
        SUMMARIZE (
            'Table',
            'Table'[Reservation],
            "Length", CALCULATE (
                MAX ( 'Table'[Length of Stay] ),
                ALLEXCEPT ( 'Table', 'Table'[Reservation] )
            )
        ),
        [Length]
    )
    
    Average Length of Stay May be for Busniness Dates 04-Jan to 05-Jan = 
    AVERAGEX (
        SUMMARIZE (
            FILTER (
                'Table',
                'Table'[Business Date]
                    IN { DATEVALUE ( "04-jan-20" ), DATEVALUE ( "05-jan-20" ) }
            ),
            'Table'[Reservation],
            "Length", CALCULATE (
                MAX ( 'Table'[Length of Stay] ),
                ALLEXCEPT ( 'Table', 'Table'[Reservation] )
            )
        ),
        [Length]
    )

     

     

     

    Community Support Team _ Jimmy Tao

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