Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ToddMate
Helper II
Helper II

MIN and MAX with grouping in another column.

Hi,

 

I am trying to determine the MIN invoice number for each customer (column A) and update the "First Invoice" column with "First" where the MIN invoice number is identified.

Same thing for MAX, except it updates the "Last Invoice" column with "Final"

I've done a mock up in excel to demonstrate what i am trying to achieve (The column names are the same in Power BI)


Annotation 2019-10-08 182912.png
Is anyone able to assist with this?

Cheers
Todd.

1 ACCEPTED SOLUTION
vik0810
Resolver V
Resolver V

Your DAX Formula for Column Last Invoice would be

 

Last Invoice =
VAR CustNo =
    VALUES ( table[Customer Number] )
VAR InvoiceNo =
    VALUES ( table[Invoice Number] )
VAR MaxInvoiceNo =
    CALCULATE (
        MAX ( table[Invoice Number] ),
        ALL ( table ),
        table[Customer Number] = CustNo
    )
RETURN
    IF ( InvoiceNo = MaxInvoiceNo, "Final" )

The formula for first invoice would be analog, just change max for min and "final" for "first"

View solution in original post

1 REPLY 1
vik0810
Resolver V
Resolver V

Your DAX Formula for Column Last Invoice would be

 

Last Invoice =
VAR CustNo =
    VALUES ( table[Customer Number] )
VAR InvoiceNo =
    VALUES ( table[Invoice Number] )
VAR MaxInvoiceNo =
    CALCULATE (
        MAX ( table[Invoice Number] ),
        ALL ( table ),
        table[Customer Number] = CustNo
    )
RETURN
    IF ( InvoiceNo = MaxInvoiceNo, "Final" )

The formula for first invoice would be analog, just change max for min and "final" for "first"

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors