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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
TimvMechelen
Frequent Visitor

Sum multiple rows based on value (Sales of old vs new material numbers) Link to example file include

Hi all,

 

First of all, I have a material master table which displays if it's a "Old" or "New" material. An "Old" material means that there is a "New" article, which is a replacement for the old article. In some of the sales analysis, I would like to take into account the sales data of both the "Old" and "New" material, which adds the sales of the "Old" material number to the "New" material number. 
So from the table below, material "4" is a replacement for material "1". Material "6" and "7" do not have "Old" material numbers.

Material Masterdata (Old - New).png

 

 

As said above, I'd like the possibility to create 2 views:

- One sales analysis with only the sales per article. This one is already correct in the file attached, see below.

Monthly sales quantity per material number.png

- One sales analysis, which takes into account the sales data of both the "Old" and "New" material, which adds the sales of the "Old" material number to the "New" material number. The figure below is what I currently have in Power BI.

Monthly sales quantity per new material number (quantity includes sales old material number).png

This is the table I'd like to see:

Material number2022-062022-072022-08Total
4222260104
    4 (new)11113052
    1 (old)11113052
555800135
    5 (new)726033
    2 (old)48540102
64571264
    6 (new)4571264
71017027
    7 (new)1017027
842234

60

    8 (new)003030
    3 (old)422430

 

Is this possible? I tried many things, but nothing works...

 

Dropbox link to Power BI example file 

Any help with this would be greatly appreciated! 

4 REPLIES 4
jgeddes
Super User
Super User

If Greg's solution does not work for you, and it is possible to add columns to the Material Masterdata Table and then use those columns to get your desired result.
Add a master material number column that assigns the new material number to any old material numbers.

Master Material Number =
if(
    not(isblank(LOOKUPVALUE('Material Masterdata'[Old material number],'Material Masterdata'[Old material number],'Material Masterdata'[Material number]))),
    LOOKUPVALUE('Material Masterdata'[Material number],'Material Masterdata'[Old material number],'Material Masterdata'[Material number]),
    'Material Masterdata'[Material number]
)
Then add a formatted text column to show new versus old material numbers
Named Material Numbers =
[Material number] & "("& [Old/New material number] & ")"
Use those two columns in your visual
jgeddes_0-1661353084747.png

And you should end up with

jgeddes_1-1661353109114.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





@jgeddes

One more question. What if there are multiple new material numbers with the same old material number? Then the formula below doesn't work anymore. I get the following error: 

"A table of multiple values was supplied where a single value was expected."


Master Material Number =

if(
    not(isblank(LOOKUPVALUE('Material Masterdata'[Old material number],'Material Masterdata'[Old material number],'Material Masterdata'[Material number]))),
    LOOKUPVALUE('Material Masterdata'[Material number],'Material Masterdata'[Old material number],'Material Masterdata'[Material number]),
    'Material Masterdata'[Material number]
)
TimvMechelen_0-1661426462599.png

In this case I'd like not to look at the old material number. So in my sales analysis, I'd like to see only the sales of the new article number. How can I fix this?

 

Thank you in advance!

@jgeddes, thank you a lot for your reply. It works!

Greg_Deckler
Community Champion
Community Champion

@TimvMechelen Perhaps have your source table like:

Material Old Material Old or new
1   Old
4 1 Old
4 4 New
7 7 New
     
     


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors