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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
laetitiaf
Frequent Visitor

Calculating invoice margin total

Hey, 

 

I'm stuck on how I can summarise the invoice margin for the whole invoice and was wondering how this can be achieved in a dax measure?

 

For example, in this table, we have each SKUs margin (in red), but next to it I want to be able to see the total margin for the same invoice number

laetitiaf_0-1730765965843.png

So the above "margin invoice total" should correlate with the below.

laetitiaf_1-1730766146094.png

 

 

1 ACCEPTED SOLUTION

Hi @laetitiaf ,

Please create a measure as below to get it and check if it can return the correct result...

Margin Invoice Total =
VAR _invnum =
    SELECTEDVALUE ( 'Table'[Invoice Number] )
RETURN
    SUMX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Invoice Number] = _invnum ),
        [Margin]
    )

If the above one can't help you figure out, please provide some raw data in your tables(exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

 

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @laetitiaf ,

Whether your problem has been resolved? If yes, could you please mark the helpful reply as Answered? It would be helpful for others in the community if they face the similar problem as yours. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@laetitiaf ,

you need a measure like

calculate([Margin], allexcept(Table, Table[Invoice Number]))

 

 

calculate([Margin], filter(allselected(Table), Table[Invoice Number]) = max(Table[Invoice Number]) ) ) 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

First syntax I get an error stating that the query has exceeded the available resources - I also have the data filtered down to todays date

Hi @laetitiaf ,

Please create a measure as below to get it and check if it can return the correct result...

Margin Invoice Total =
VAR _invnum =
    SELECTEDVALUE ( 'Table'[Invoice Number] )
RETURN
    SUMX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Invoice Number] = _invnum ),
        [Margin]
    )

If the above one can't help you figure out, please provide some raw data in your tables(exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

 

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.