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
pianobleman7
Frequent Visitor

Question for Sum with specific conditions in Power BI

ItemMother ItemSales
A 1
BA2
BA1
CD3
D 4
E 2
E 4
Total 17

I have former sales table. 

Some of Item has a mother item(B's mother item is "A", "C"'s mother items is"D", and "E" doesn't have a mother item.) I would like to sum up the sales of each item like below.

 

A and B have the value samely summing "A" sales Sum + "B" sales Sum (1+2+1=4)

C and B have the value samely summing "C" sales Sum + "D" sales Sum(3+3=6)

E  has sales 2pcs and 4pcs all together 6pcs. is it possible?

 

Total sales should be 17 as below.

ItemSales Sum
A4
B4
C7
D7
E6
Total17
2 ACCEPTED SOLUTIONS

Hi @pianobleman7 

You can refer to the following measure

 

Sum = var a=SUMMARIZE(FILTER(ALL('Table'),[Item]=SELECTEDVALUE('Table'[Item])),[Item])
var b=SUMMARIZE(FILTER(ALL('Table'),[Item]=SELECTEDVALUE('Table'[Item])),[Blank Item])
return SUMX(FILTER(ALL('Table'),OR([Item] in SUMMARIZE(FILTER(ALL('Table'),OR('Table'[Item]=SELECTEDVALUE('Table'[Item]),[Blank Item]=SELECTEDVALUE('Table'[Item]))),[Item]),[Item] in UNION(a,b))),[Sales])

 

Output

vxinruzhumsft_0-1681267536823.png

Best Regards!

Yolo Zhu

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

Hi @pianobleman7 

Just create a new measure

Measure 2 = SUMX(VALUES('Table'[Item]),[Sum])
and put it to the table, and the total should be 28.
vxinruzhumsft_0-1681268469145.png

Best Regards!

Yolo Zhu

 

View solution in original post

9 REPLIES 9
lbendlin
Super User
Super User

According to your sample data the sum for A should be 3 ?

I've changed "blank item" terms to relative item.

I want to sum each item's Sales both original item and relative item.

so relative item and original item could have same sum value as example.

The second B item does not have a related A item.

sorry my bad.

I've changed it.

v-xinruzhu-msft
Community Support
Community Support

Hi 

!?!?!?!?

Hi @pianobleman7 

You can refer to the following measure

 

Sum = var a=SUMMARIZE(FILTER(ALL('Table'),[Item]=SELECTEDVALUE('Table'[Item])),[Item])
var b=SUMMARIZE(FILTER(ALL('Table'),[Item]=SELECTEDVALUE('Table'[Item])),[Blank Item])
return SUMX(FILTER(ALL('Table'),OR([Item] in SUMMARIZE(FILTER(ALL('Table'),OR('Table'[Item]=SELECTEDVALUE('Table'[Item]),[Blank Item]=SELECTEDVALUE('Table'[Item]))),[Item]),[Item] in UNION(a,b))),[Sales])

 

Output

vxinruzhumsft_0-1681267536823.png

Best Regards!

Yolo Zhu

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

 

Thanks for your reply.

it works very well. however, could I have total sum ?17 at the bottom of table?

Hi @pianobleman7 

Just create a new measure

Measure 2 = SUMX(VALUES('Table'[Item]),[Sum])
and put it to the table, and the total should be 28.
vxinruzhumsft_0-1681268469145.png

Best Regards!

Yolo Zhu

 

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.