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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
LukeDrako
Regular Visitor

table not summing

Hi, this is probably something simple... but I can't get it to work...

I created a measure to get the cost. For some reason it is not summarizing correctly. 

This is the Measure

Cost2 =
var totalcompletedhours = SUM(Task[CompletedWork])
var cost_hour_default = LOOKUPVALUE(Activity[Value],Activity[Activity],"Default")
var total_Cost =  SUMX(Task,Task[CompletedWork]*RELATED(Activity[Value]))
var result = SWITCH(
    true,
    totalcompletedhours = 0,BLANK(),
    total_Cost = BLANK(), totalcompletedhours * cost_hour_default, -- Gets default value cost if activity doesn't exists
    total_Cost
)
RETURN
result
 

This is the table you can see the yellow has not been summed. 

LukeDrako_0-1745525474404.png

 

Any ideas on how to resolve?

1 ACCEPTED SOLUTION
LukeDrako
Regular Visitor

I solved this at the end... I neede to use the USERPRINCIPAL() function so thats why I needed a measure. 
At the ned I created a column field with the above logic and then created a measure referencing the column and using the userprincipla(). 

 

Below the code I used to reference the column with above logic and added the userprincipal. 

Cost =
var total_Cost = SUM(Task[Cost_])
RETURN
if(LOWER(USERPRINCIPALNAME()) = "lblablabvlsa" || LOWER(USERPRINCIPALNAME()) = "blblbl",total_Cost,BLANK())
 


It worked

View solution in original post

6 REPLIES 6
LukeDrako
Regular Visitor

I solved this at the end... I neede to use the USERPRINCIPAL() function so thats why I needed a measure. 
At the ned I created a column field with the above logic and then created a measure referencing the column and using the userprincipla(). 

 

Below the code I used to reference the column with above logic and added the userprincipal. 

Cost =
var total_Cost = SUM(Task[Cost_])
RETURN
if(LOWER(USERPRINCIPALNAME()) = "lblablabvlsa" || LOWER(USERPRINCIPALNAME()) = "blblbl",total_Cost,BLANK())
 


It worked

V-yubandi-msft
Community Support
Community Support

Hi @LukeDrako ,

We haven’t received a response yet and want to ensure the solution met your needs. If you need any further assistance, feel free to reach out we’d be happy to help. If everything is working as expected, kindly mark it as Accepted as solution.

 

Thank You.

V-yubandi-msft
Community Support
Community Support

Hi @LukeDrako ,

Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
Thank you.

Ashish_Mathur
Super User
Super User

Hi,

LOOKUPVALUE() function is used as a calculated column (not as a measure).  To get specific help, share some data, explain the question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
kushanNa
Solution Sage
Solution Sage

Hi @LukeDrako 

 

I remember @Tutu_in_YYC fixed a similar issue , check if this helps you ? 

 

https://community.fabric.microsoft.com/t5/Desktop/summing-time-utilization/td-p/4615038 

Yup similar issue. Especially @LukeDrako  is using switch statement in the result.

The reason why it is returning 4097, is probably because its returning only one of the cases in the switch statement instead of summing it.

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.