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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
SvenJ
Helper III
Helper III

Adding a sum to a table from list

Good morning,

 

i have a list with values and a specific "position", which is a clear value at the table: 

lista a.PNG

 

Here is the table 

table A.PNG

 

How can i get the list filled with the sum of the positions as shown in the example above. It would be great to get your help.

1 ACCEPTED SOLUTION

Hi,

Total calculation logic uses the same dax as within the columns/rows it is trying to calculate total. However in the total calculation filter context e.g. using SELECTEDVALUE() return blanks. To combat this you can change the calculation logic of the measure for total values e.g. IF(SELECTEDVALUE('Table'[month])=blank(),[total calculation logic],[original calculation logic])





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

Proud to be a Super User!




View solution in original post

10 REPLIES 10
SvenJ
Helper III
Helper III

Great! Thanks for your help!

SvenJ
Helper III
Helper III

@ValtteriN Thanks a lot - this helps! I think you switched the table names in one post, as i get the values from the list and not the table. Anyway, i found the problem. Another question. Is there a reason, why i don´t get the total amount in columns and rows? 

Unbenannt total.PNG

Hi,

Total calculation logic uses the same dax as within the columns/rows it is trying to calculate total. However in the total calculation filter context e.g. using SELECTEDVALUE() return blanks. To combat this you can change the calculation logic of the measure for total values e.g. IF(SELECTEDVALUE('Table'[month])=blank(),[total calculation logic],[original calculation logic])





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

Proud to be a Super User!




SvenJ
Helper III
Helper III

@ValtteriN Thanks for the explanation. Where do i have to add the measure or function? Is the function correct? I don´t see the part where you grab the value from the INCOMING (list)?

@SvenJ 

I understood you want the values from the table with month names as columns. Did I misunderstand. In the DAX I categorize whether or not values are incoming or out going based on if they are positive or negative and then I created two measures based on this. E.g. if the value is -5 for position 4444 in January the result is outgoing = -5 and incoming = blank() for the month and position in question. 





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

Proud to be a Super User!




@ValtteriN No, the other way around. I want to read the values from the list and want the sum in the table with month

This clarifies things, 

The unpivot step remains the same, but instead of 2 measures we can use one.

Example data with incoming + outgoing columns:

ValtteriN_1-1642369491790.png

 

Dax:

Incoming/outgoing = var _m =SELECTEDVALUE(Incoming[Month])
var _p = SELECTEDVALUE(Incoming[Position])
var _value = calculate(SUM(IncomingFact[Incoming])-SUM(IncomingFact[OutGoing]),all(IncomingFact),IncomingFact[Month]=_m,IncomingFact[Position]=_p)
return

_value
 
End result:
ValtteriN_0-1642369437436.png

 





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

Proud to be a Super User!




ValtteriN
Super User
Super User

Hi,

You could Unpivot the table and then create either a columns or a measures for incoming and outgoing amounts. Additionally link the two tables with dimension tables. The condition for incoming and outgoing can be their value direction.

E.g. Incoming = IF(sum('Incomingfact'[Value])>=0,sum('Incomingfact'[Value]),BLANK())

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!






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

Proud to be a Super User!




Thanks for your answer. Can you give me an example? I´m new on Power Bi and can´t follow you 100%

Okay,

So for the steps:

Unpivot:
Select a column in powerquery and "unpivot other columns" or in this case select month column January, February....

ValtteriN_0-1642355177861.png

You get a table like this:

ValtteriN_1-1642355209862.png


Dimension tables:

So with this I mean tables that act as a slicer in between your two tables e.g. Calendar with Month column or a list of all the positions. Alternatively you can ignore this step and modify the measures for incoming and outgoing. 

As an example here 'IncomingFact' table is a table that I unpivoted and 'Incoming' Table is the "list" table:

Incoming =
var _m =SELECTEDVALUE(Incoming[Month])
var _p = SELECTEDVALUE(Incoming[Position])
var _value = calculate(SUM(IncomingFact[Value]),all(IncomingFact),IncomingFact[Month]=_m,IncomingFact[Position]=_p)
return
IF(_value>0,_value,BLANK())
 
tables and end result using this dax:
'Incoming'
ValtteriN_2-1642355719541.png


'IncomingFact'

ValtteriN_3-1642355740251.png


End result:

ValtteriN_4-1642355802265.png

 

For outgoing I reversed the "<" condition


This should be a more detailed explanation. Ping me with @ if you still have questions.





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

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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