cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
electrobrit
Post Patron
Post Patron

Simple Sum of a measure not working

I have created a column for standard working hours where everyone is 40 hours except PersonA is 20 
My table is TimeDetail-fyi


2_Std Working Hours =

    SWITCH(
        TRUE(),
        SELECTEDVALUE(TimeDetail[full_name]) = "PersonA",20,40)

then when I add to column, I don't get a column total with it all added, instead just 40

electrobrit_0-1665094684375.png

Like

PersonA20  
PersonB40  
PersonC40  
Total40(should be 100)


So I added a measure to try to add them up. 
I'm sure it's a dax thing but why can't I do this?
4StdWorkingHours = SUM(TimeDetail[2Std Working Hours])
(Error: Column '2Std Working Hours' in table 'TimeDetail' cannot be found or may not be used in this expression.)

4StdWorkingHours = SUM(TimeDetail, TimeDetail[2_Std Working Hours])
(Error: Too many arguments were passed to the SUM function. The maximum argument count for the function is 1.)

how can I do this?
1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @electrobrit ;

You could try to change the meausre :

2_Std Working Hours = 
IF(
       MAX(TimeDetail[full_name]) = "PersonA",20,40)
Measure = SUMX(SUMMARIZE('TimeDetail',[full_name],"1",[2_Std Working Hours]),[1])

The final show:

vyalanwumsft_0-1665390322328.png


Best Regards,
Community Support Team _ Yalan Wu
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

8 REPLIES 8
v-yalanwu-msft
Community Support
Community Support

Hi, @electrobrit ;

You could try to change the meausre :

2_Std Working Hours = 
IF(
       MAX(TimeDetail[full_name]) = "PersonA",20,40)
Measure = SUMX(SUMMARIZE('TimeDetail',[full_name],"1",[2_Std Working Hours]),[1])

The final show:

vyalanwumsft_0-1665390322328.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

That worked perfect! thank you

MahyarTF
Memorable Member
Memorable Member

Hi,

Did you create the measure or column ?

I create the same column with Calculate statement and it seems it is working properly :

2_Std Working Hours =
    CALCULATE(SWITCH(
        TRUE(),
        SELECTEDVALUE(Sheet226[Fullname]) = "PersonA",20,40))
MahyarTF_0-1665096817065.png

Thanks for your Kudos.

Please select it as a solution if it helps you.

Mahyartf
hnguy71
Memorable Member
Memorable Member

@electrobrit , your "calculated column" is likely a measure since within a calculated column we typically don't use SELECTEDVALUE.

A typical calculated column would look similar to this:

2_Std Working Hours = IF(TimeDetail[full_name] = "A",20, 40)

 

Then you can create a measure to sum up that new calculated column:

TotalHours := SUM(TimeDetail[full_name])

 

A calculated column would have this icon:

hnguy71_0-1665095939225.png

 

 

A measure would have this icon:

 

hnguy71_1-1665095957262.png

 

Let me know if that helps!

 

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

It was a measure. Thank you for that little lesson.
So when I sum it up, I have it filtered by date and it's bringing back all the hours. It seems like typically Power Bi would do this automatically but it doesn't. Is my measure incorrect?

electrobrit_1-1665097160205.png

 

 

@electrobrit can you try posting your new measure?



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Thank you!

Column: 2_Std Working Hours =
IF(TimeDetail[full_name]="PersonA", 20, 40)

Measure: 

4StdWorkingHours = SUM(TimeDetail[2_Std Working Hours])
electrobrit_1-1665117082202.png

 


 

Hi @electrobrit ,

Without seeing your model, I can only deduct that two possible reasons:

 

 

1. Your period_end_date field is not associated with your employee or resource type field.

2. Each employee has multiple records per period. For example, the first person has 17 records on 9/10/2022 while the last person has 4 records.

 

Could you supply a sample model?



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors