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! Learn more

Reply
dreaves1
Helper II
Helper II

How to create a calculated column

I have a openings table and a hires table and they both have a unquie identifier and unique company in them. I'm looking to create a calculated column titled "Opening remaining" in the openings table that will subtract the number of openings based on the number of hires in the hire tables. How can I get this accomplished?

 

dreaves1_0-1599840710061.pngdreaves1_1-1599840732877.png

 

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @dreaves1 ,

You can create this calculated column in your opening table:

Opening remaining = 
VAR _count =
    CALCULATE (
        COUNT ( 'hires'[Hires] ),
        'hires'[Company Name] = EARLIER ( openings[Company Name] ),
        'hires'[SubCompany Name] = EARLIER ( openings[SubCompany Name] )
    )
RETURN
    'openings'[Total Openings] - _count

remain.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

5 REPLIES 5
v-yingjl
Community Support
Community Support

Hi @dreaves1 ,

You can create this calculated column in your opening table:

Opening remaining = 
VAR _count =
    CALCULATE (
        COUNT ( 'hires'[Hires] ),
        'hires'[Company Name] = EARLIER ( openings[Company Name] ),
        'hires'[SubCompany Name] = EARLIER ( openings[SubCompany Name] )
    )
RETURN
    'openings'[Total Openings] - _count

remain.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

amitchandak
Super User
Super User

@dreaves1 ,Not very clear

 

Can you share sample data and sample output in table format?

 

Typically you can add subtract measure from two tables across common tables or grand total

 

Sum(Tables1[Value]) -Sum(Tables2[Value])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you so much for your help! I've included some sample data on how my data looks in the post

Greg_Deckler
Community Champion
Community Champion

@dreaves1 Maybe:

 

Opening remaining =
  [Openings] - COUNTROWS(RELATEDTABLE('Hires')) 
  

Assuming a relationship, if not:

Opening remaining = 
  [Openings] - COUNTROWS(FILTER('Hires','Hires'[Company] = 'Openings'[Company]))

Filter criteria will vary depending on your data, I am not sure what you have exactly.

 



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

Thank you so much for your help!

 

I've included some sample data on what my tables look like.

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.