cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lc1 Helper III
Helper III

Sum numeric values using filters

Hello,

I have two columns PAR_Hours which are numeric values and PAR_Codes which are text values. I need to sum all hours for specific codes (LN, LD and DR)

I tried using several versions of this formula to no avail, results are always blank.

 

CALCULATETABLE(VALUES(Absenteeism[PAR_HOURS]),filter(Absenteeism,Absenteeism[PAR_CODE]="LN"&"LD"&"DR"))
 
CALCULATE(SUM(Absenteeism[PAR_HOURS]),Absenteeism[PAR_CODE]="LN",Absenteeism[PAR_CODE]="LD",Absenteeism[PAR_CODE]="DR")
 
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User IV
Super User IV

Re: Sum numeric values using filters

Hi,

Try this measure

=CALCULATE(SUM(Absenteeism[PAR_HOURS]),Absenteeism[PAR_CODE]="LN"||Absenteeism[PAR_CODE]="LD"||Absenteeism[PAR_CODE]="DR")

Hope this helps.


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

View solution in original post

6 REPLIES 6
Super User IV
Super User IV

Re: Sum numeric values using filters

Try

CALCULATETABLE(VALUES(Absenteeism[PAR_HOURS]),filter(Absenteeism,Absenteeism[PAR_CODE] in {"LN","LD","DR"}))
OR
CALCULATETABLE(VALUES(Absenteeism[PAR_HOURS]),filter(all(Absenteeism),Absenteeism[PAR_CODE] in {"LN","LD","DR"}))




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
In case it does not help, please provide additional information and mark me with @
My Recent Blog -Week is not so Weak Proud to be a Super User! Connect on Linkedin


lc1 Helper III
Helper III

Re: Sum numeric values using filters

It didn't work, got an error:

MdxScript (Model 8, 37)...A table of multiple values was supplied where a single value was expected.

Community Support
Community Support

Re: Sum numeric values using filters

Hi @lc1 ,

 

Try this measure:

 

Measure=
CALCULATE(
    SUM(Absenteeism[PAR_HOURS]),
    FILTER(
        Absenteeism,
        Absenteeism[PAR_CODE] in {"LN", "LD", "DR"}
    )
)

OR

Measure1=
CALCULATE(
    SUM(Absenteeism[PAR_HOURS]),
    FILTER(
       ALL(Absenteeism),
        Absenteeism[PAR_CODE] in {"LN", "LD", "DR"}
    )
)

 

"MdxScript (Model 8, 37)...A table of multiple values was supplied where a single value was expected."

VALUES(Absenteeism[PAR_HOURS]) will return a single column table, however, you what you created is a measure, so the program reports an error.

VALUES() function 

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Highlighted
Super User IV
Super User IV

Re: Sum numeric values using filters

Hi,

Try this measure

=CALCULATE(SUM(Absenteeism[PAR_HOURS]),Absenteeism[PAR_CODE]="LN"||Absenteeism[PAR_CODE]="LD"||Absenteeism[PAR_CODE]="DR")

Hope this helps.


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

View solution in original post

lc1 Helper III
Helper III

Re: Sum numeric values using filters

Thank you, it worked!

Super User IV
Super User IV

Re: Sum numeric values using filters

You are welcome.


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

Helpful resources

Announcements
‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

April 2020 Community Highlights

April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors