Forum Discussion

Mamoun_issa's avatar
Mamoun_issa
Frequent Visitor
5 years ago

Latest Invoice Amount - Iternation

Hello,

 

I Have a table of invoices to that was submitted to the health insurance company that looks similar to this:

 

Invoice No.Mode (1- submission, 2- Resubmissition, 3- Correction)Amount
VAN100011100
VAN100012100
VAN100021500
VAN100023420
VAN100031800
VAN100033950
VAN100032950

 

 

I want to create a column that has the latest invoice Amount where any correction happend, smiliar to below

 

Invoice No./Amount
VAN10001100
VAN10002420
VAN10003950

6 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Mamoun_issa - You could do that as a measure in a table visualization with Invoice No. I mocked it up and provided a sample PBIX for you. It is Table (10), Measure (10) on Page 10.

    Measure 10 = 
        VAR __ModeMax = MAX([Mode])
    RETURN
        MAXX(FILTER('Table (10)',[Mode] = __ModeMax),[Amount])

    See attached PBIX below sig. 

  • Mamoun_issa 

    You can add a new column with the code below:

    Latest Amount = 
    VAR M = 
        CALCULATE(
            MAX(Table1[Mode]),
            ALLEXCEPT(Table1,Table1[Invoice No.])
        )
    VAR I = 
        CALCULATE(
            MAX(Table1[Invoice No.]),
            Table1[Mode] = M,
            ALLEXCEPT(Table1,Table1[Invoice No.])
        )
    RETURN
    
    IF( Table1[Invoice No.]=I && Table1[Mode] = M , Table1[Amount] , BLANK() )

     

     

    ________________________

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

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

    YouTube  LinkedIn

     

  •  

    I'v solved your problem based on the assumption that each invoice no has at most 3 times for submission

    please let me know if it works for you