cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Meeresblume
Frequent Visitor

Only the highest invoice number per project should be taken into account

Hi there,

I have a table in Power BI. This table contains project numbers, clerks, invoice numbers, amount and a date.
There can be several invoice numbers with different date for a project.

 

Now I would like to create a report that contains 2 data slicers. Once for the date (from-to) and once for the clerk.
In addition, the amount should be totaled out.

So far no problem. However, I would like only the highest invoice number per project to be included in the total.

 

Here's an example:

Meeresblume_0-1638834961628.png

 

When filtering by date January 01, 2021 and clerk A
Result: 80 (invoice number 1 and 8 )
When filtering by date January 01, 2021 and clerk B
Result: 15 (invoice number 4)
When filtering by date January 02, 2021 and clerk A
Result: 25 (ONLY invoice number 3 and 7, NOT also number 2)
When filtering by date January 02, 2021 and clerk B
Result: 10 (ONLY invoice number 6, NOT also number 5)

 

Hope it's understandable 🙂

How exactly can I ensure that only the highest invoice number per project is taken into account in the amount, in addition to the filtered date and person responsible?

 

thank you for your help 🙂

LG

1 ACCEPTED SOLUTION

Hi, @Meeresblume 

Try  formula as below, it may be a bit clumsy:

amount of max invoice number = 
VAR _max_invoice_number =
    CALCULATE (
        MAX ( 'Table'[invoice number] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Project number] = MIN ( 'Table'[Project number] )
        )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[amount] ),
        FILTER ( 'Table', 'Table'[invoice number] = _max_invoice_number )
    )
Result = 
VAR tab =
    SUMMARIZE (
        'Table',
        'Table'[Project number],
        "s_amount", [amount of max invoice number]
    )
RETURN
    SUMX ( tab, [s_amount] )

Please check my sample file for more details.

 

Best Regards,
Community Support Team _ Eason

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Meeresblume , Try a measure like this with project number and date in visual

 

Measure =
VAR __id = MAX ('Table'[Project Number] )
VAR __date = CALCULATE ( MAX('Table'[Date] ), ALLSELECTED ('Table' ), 'Table'[Project Number] = __id )
CALCULATE ( Sum ('Table'[Amount] ), VALUES ('Table'[Project Number] ),'Table'[Project Number] = __id,'Table'[Date] = __date )

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

@amitchandak  

Thanks for your answer.
However, the measure would not work.

I need the highest offer number per project, but depending on my filter with the date and the person responsible, the amount that is totaled.

The way I interpret the measure from you, I would only make this out by attaching the project number and the max date. But not from my filtered date + clerk.

Hi, @Meeresblume 

Try  formula as below, it may be a bit clumsy:

amount of max invoice number = 
VAR _max_invoice_number =
    CALCULATE (
        MAX ( 'Table'[invoice number] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Project number] = MIN ( 'Table'[Project number] )
        )
    )
RETURN
    CALCULATE (
        MAX ( 'Table'[amount] ),
        FILTER ( 'Table', 'Table'[invoice number] = _max_invoice_number )
    )
Result = 
VAR tab =
    SUMMARIZE (
        'Table',
        'Table'[Project number],
        "s_amount", [amount of max invoice number]
    )
RETURN
    SUMX ( tab, [s_amount] )

Please check my sample file for more details.

 

Best Regards,
Community Support Team _ Eason

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!