Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

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. 

 

Any ideas on how to resolve?

  • Anonymous's avatar
    Anonymous
    1 year ago

    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

6 Replies

    • Tutu_in_YYC's avatar
      Tutu_in_YYC
      Super User

      Yup similar issue. Especially Anonymous  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.

  • 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.

  • V-yubandi-msft's avatar
    V-yubandi-msft
    Community Support

    Hi Anonymous ,

    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.

  • V-yubandi-msft's avatar
    V-yubandi-msft
    Community Support

    Hi Anonymous ,

    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.

  • Anonymous's avatar
    Anonymous
    Not applicable

    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