Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Fetch First and Last Date Value based on Date Slicer Selection

Hi ,     For each GL_Account field (100,101 etc) i need to take first and last Posting_Date Row  and copy Opening and Closing value to new columns Opening_New and Closing_New . These Posting_Date...
  • v-jiascu-msft's avatar
    7 years ago

    Hi Anonymous,

     

    There are many approaches. Since something isn't clear about the data, I created a solid solution. Please download the demo from the attachment.

    1. Add an index in the Query Editor.

    2. Create two measures.

    Opening_New =
    VAR minIndex =
        CALCULATE (
            MIN ( Table1[Index] ),
            ALLSELECTED ( Table1[Posting_Date] ),
            ALLEXCEPT ( Table1, Table1[GL_Account], Table1[Posting_Date] )
        )
    RETURN
        IF (
            MIN ( Table1[Index] ) = minIndex,
            CALCULATE ( SUM ( Table1[Opening] ), Table1[Index] = minIndex ),
            0
        )
    
    Closing_New =
    VAR maxIndex =
        CALCULATE (
            MAX ( Table1[Index] ),
            ALLSELECTED ( Table1[Posting_Date] ),
            ALLEXCEPT ( Table1, Table1[GL_Account], Table1[Posting_Date] )
        )
    RETURN
        IF (
            MIN ( Table1[Index] ) = maxIndex,
            CALCULATE ( SUM ( Table1[Closing] ), Table1[Index] = maxIndex ),
            0
        )
    

    Fetch-First-and-Last-Date-Value-based-on-Date-Slicer-Selection

     

    Best Regards,