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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jcastr02
Post Prodigy
Post Prodigy

Sum of Values in same table but with filters

count.pngI have a table with a count column (value) and a count type column   (either Headcount or Terms).

 

How can I get a measure to divide the       sum of headcount   /    sum of terms          

13 REPLIES 13
Greg_Deckler
Community Champion
Community Champion

@jcastr02 - So, should be something like:

 

Measure =
  DIVIDE(
    SUMX(FILTER(ALL('Table'),[Type]="Headcount"),[Count]),
    SUMX(FILTER(ALL('Table'),[Type]="Terms"),[Count]),
    0
  )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

apologies @Greg_Deckler        Meant to say         Sum of Terms    /     AVERAGE of Headcount        -- flipped around. 

 

I tried to do AverageX in it's place but didn't work...

@jcastr02 - Not sure why this wouldn't work

Measure =
  DIVIDE(
    SUMX(FILTER(ALL('Table'),[Type]="Terms"),[Count]),
    AVERAGEX(FILTER(ALL('Table'),[Type]="Headcount"),[Count]),
    0
  )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Hello, It seems that the measure stays static, so when I click on example 9/1/2019 I should see % being 252/3798 = 6.63%, but no matter what date I click on, the number stays the same for the measure created. count12345.png

@jcastr02 - Use ALLSELECTED instead of ALL



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler    Still seems to do incorrect calculation - as example for 11/1/2019 & 12/1/2019....... 

 

Sum of Terms =   309+265=574

Average of Headcount = 7,511 / 2   = 3,755.5

 

Attrition =  574 / 3,755.5 = 15.28%

 

55.png

@Greg_Deckler   Any ideas on how I can achieve this?  I appreciate your help.

@jcastr02 - Post sample data as text and expected output and I will take a look

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler   Thanks for your help - I added some sample data in red box in image

 

dexler.png

Hello @Greg_Deckler I added some sample data above, any luck with that one?  Thanks so much and appreciate the help. 

Hi @jcastr02 ,

 

Please try this:

Measure =
VAR terms =
    CALCULATE ( SUM ( 'Table'[Count] ), 'Table'[Count Type] = "Terms" )
VAR Headcount =
    AVERAGEX (
        ALL ( 'Table'[File_date1] ),
        CALCULATE ( SUM ( 'Table'[Count] ), 'Table'[Count Type] = "Headcount" )
    )
RETURN
    DIVIDE ( terms, Headcount )

v-xuding-msft_0-1599635120736.png

 

 

 

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

Thanks so so much @v-xuding-msft    It looks like I'm close - when I do my measure I get 12.71%, but should be 12.55% - Are you able to double check me?  Thanks again for help..

 

count.count.png

@v-xuding-msft   any help would be appreciated on above..thanks in advance

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors