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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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])

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

Greg_Deckler
Super User
Super User

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

 


@ 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!:
The Definitive Guide to Power Query (M)

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
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.