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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Implement Aggregate Sum column based on values from other columns

Hello All I wish to implement a column D as shown in below screenshot using DAX measure such that Column D aggregation is sum of values in Column C. For Example, Value in Row number D3 is sum of values from Rows C3 to C8 such that it is aggregated on same supplier value from Column A from row A3 to A8 and the sum in row D3 must also correspond to MDF in row B3 with highest value in row C3. Is this possible to achieve in Power BI table visual using DAX ??

sha009_0-1649142746758.png

 

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

I assume you want to create a new calculated column.

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Total Supplier Spend CC =
VAR _currentsupplier = Data[Supplier]
VAR _suppliertable =
    FILTER ( Data, Data[Supplier] = _currentsupplier )
VAR _maxsupplierspend =
    MAXX ( _suppliertable, Data[SupplierSpend] )
VAR _condition = Data[SupplierSpend] = _maxsupplierspend
RETURN
    SUMX ( _suppliertable, Data[SupplierSpend] ) * DIVIDE ( _condition, _condition )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

Anonymous
Not applicable

@Anonymous 

Please see the solution using a 'Measure':

shwetadalal_0-1649167971191.png

 

Dax Code:

 

sumn =
VAR maxval =
MAXX (
FILTER ( ALL ( Data ), Data[Supplier] = SELECTEDVALUE ( Data[Supplier] ) ),
Data[SupplierSpend]
)
VAR summ =
CALCULATE (
SUMX (
FILTER ( ALL ( Data ), Data[Supplier] = SELECTEDVALUE ( Data[Supplier] ) ),
Data[SupplierSpend]
)
)
VAR conditions =
SELECTEDVALUE ( Data[SupplierSpend] ) = maxval
RETURN
IF ( summ * conditions > 0, summ * conditions, BLANK () )
 
 
Also, you need to enable 'Show Items with No Data' for supplier as I have shown in following image:
Also enable 'Don't Summarize' for all fields.
shwetadalal_1-1649168053111.png

 

 
 
Please accept it as a solution if it matches your requirement🙂
 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@Anonymous 

Please see the solution using a 'Measure':

shwetadalal_0-1649167971191.png

 

Dax Code:

 

sumn =
VAR maxval =
MAXX (
FILTER ( ALL ( Data ), Data[Supplier] = SELECTEDVALUE ( Data[Supplier] ) ),
Data[SupplierSpend]
)
VAR summ =
CALCULATE (
SUMX (
FILTER ( ALL ( Data ), Data[Supplier] = SELECTEDVALUE ( Data[Supplier] ) ),
Data[SupplierSpend]
)
)
VAR conditions =
SELECTEDVALUE ( Data[SupplierSpend] ) = maxval
RETURN
IF ( summ * conditions > 0, summ * conditions, BLANK () )
 
 
Also, you need to enable 'Show Items with No Data' for supplier as I have shown in following image:
Also enable 'Don't Summarize' for all fields.
shwetadalal_1-1649168053111.png

 

 
 
Please accept it as a solution if it matches your requirement🙂
 
Anonymous
Not applicable

@Anonymous 

Can you please accept it as a solution if it matched your requirement!

Jihwan_Kim
Super User
Super User

Hi,

I assume you want to create a new calculated column.

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Total Supplier Spend CC =
VAR _currentsupplier = Data[Supplier]
VAR _suppliertable =
    FILTER ( Data, Data[Supplier] = _currentsupplier )
VAR _maxsupplierspend =
    MAXX ( _suppliertable, Data[SupplierSpend] )
VAR _condition = Data[SupplierSpend] = _maxsupplierspend
RETURN
    SUMX ( _suppliertable, Data[SupplierSpend] ) * DIVIDE ( _condition, _condition )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

@Jihwan_Kim Thanks for the solution but can I also get this as a DAX measure.

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.