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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

The code is needed for ABC analysis

Hey,

 

I'm new to the DAX desktop app and I'm having trouble creating the code.

 

I have two tables. I want to add the sum of all orders from the same vendor from the first table to the second table.

 

The supplier is marked as text. (Its name) A supplier has multiple orders, I want to calculate the order amount of the same supplier (from the Orders table) to another table (sum_of_all_orders_from_supplier).

 

I've tried many calculations, but I didn't get any code that would work.

 

So I want to do an ABC analysis of suppliers, so I first need a code that calculates the amounts in euros for each supplier’s total order.

 

Thanks for the help in advance

 

matomatala_1-1624949215710.png

 

 

3 ACCEPTED SOLUTIONS
selimovd
Super User
Super User

Hey @Anonymous ,

 

an approach that should always work is the following:

Sum Supplier =
VAR vRowSupplier = secondTable[supplier]
RETURN
    CALCULATE(
        SUM( firstTable[order amount] ),
        firstTable[supplier] = vRowSupplier
    )

 

If you would give more details about the relationship also easier approaches could probably be done.

In general for ABC analysis check out the following article:

ABC classification – DAX Patterns

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

You don't need to create sum measure, when add it to table, it will sum automatically:

vluwangmsft_0-1625128277771.pngvluwangmsft_1-1625128290032.png

If you also want to create a new column ,you could use the following dax :

sum = SUMX (
    FILTER ( 'Table', 'Table'[supplier] =Table2[supplier]),
    'Table'[order amount]
)

Final get:

vluwangmsft_2-1625128342882.png

And you also could use the following dax to create a new table ,base on base data table:

Table3 = SUMMARIZE('Table','Table'[supplier],"total",sum('Table'[order amount]))

vluwangmsft_3-1625128449596.png

 

Wish it is helpful for you!

 

 

Best Regards

Lucien

View solution in original post

Anonymous
Not applicable

Thank you both 😍 I made three counters with your help and all of them worked fine. You no longer have to decide which counter I will use.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thank you both 😍 I made three counters with your help and all of them worked fine. You no longer have to decide which counter I will use.

v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

You don't need to create sum measure, when add it to table, it will sum automatically:

vluwangmsft_0-1625128277771.pngvluwangmsft_1-1625128290032.png

If you also want to create a new column ,you could use the following dax :

sum = SUMX (
    FILTER ( 'Table', 'Table'[supplier] =Table2[supplier]),
    'Table'[order amount]
)

Final get:

vluwangmsft_2-1625128342882.png

And you also could use the following dax to create a new table ,base on base data table:

Table3 = SUMMARIZE('Table','Table'[supplier],"total",sum('Table'[order amount]))

vluwangmsft_3-1625128449596.png

 

Wish it is helpful for you!

 

 

Best Regards

Lucien

selimovd
Super User
Super User

Hey @Anonymous ,

 

an approach that should always work is the following:

Sum Supplier =
VAR vRowSupplier = secondTable[supplier]
RETURN
    CALCULATE(
        SUM( firstTable[order amount] ),
        firstTable[supplier] = vRowSupplier
    )

 

If you would give more details about the relationship also easier approaches could probably be done.

In general for ABC analysis check out the following article:

ABC classification – DAX Patterns

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

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.