Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to get value on latest date based on multiple columns?

Hello all, I have dataframe like below:   Country City Neighbourhood Date     Value  ExpectedValue AX BY CT 1/14/2021       1 1 AX BY CT 1/13...
  • Fowmy's avatar
    5 years ago

    Anonymous 

    Add this code as a new column to your table. Replace table and column names as necessary.

    Exp Value = 
    var __Date = 
    MAXX(
        FILTER(
            'Table 7',
            'Table 7'[Country] = EARLIER('Table 7'[Country]) &&
            'Table 7'[City] = EARLIER('Table 7'[City]) &&
            'Table 7'[Neighbourhood] = EARLIER('Table 7'[Neighbourhood])      
        ),
        'Table 7'[Date]
    )
    
    var __Value = 
        MAXX(
        FILTER(
            'Table 7',
            'Table 7'[Country] = EARLIER('Table 7'[Country]) &&
            'Table 7'[City] = EARLIER('Table 7'[City]) &&
            'Table 7'[Neighbourhood] = EARLIER('Table 7'[Neighbourhood]) && 
            'Table 7'[Date] = __Date    
        ),
        'Table 7'[    Value]
    )
    
    return
    
    __Value

     

    ________________________

    If my answer was helpful, please click Accept it as the solution to help other members find it useful

    Click on the Thumbs-Up icon if you like this reply 🙂


    Website YouTube  LinkedIn