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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Jadegirlify
Helper I
Helper I

Calculated Column based on Column Value

I need to create a calculation showing departments counts of employees working onsite vs virtual. I tried several measures/calculated column but I was stuck at the "Work Location Type" column. It won't do a distinct count of the departments. Please see the result table I am trying to achieve. The last column uses the following criteria:

If Onsite is 0 and Virtual >0 return "Virtual"

If Onsite >0 and Virtual = 0 return "Onsite"

If Onsite > 0 and Virtual > 0 return "Onsite & Virtual "

 

Original Table

DepartmentWork Location
HROnsite
HROnsite
HROnsite
HROnsite
Claims Onsite
Claims Virtual
UnderwritingOnsite
UnderwritingOnsite
UnderwritingVirtual
UnderwritingVirtual
UnderwritingVirtual
OperationsVirtual
OperationsVirtual

 

Result Table

DepartmentOnsiteVirtualTotal Onsite/VirtualWork Location Type
HR404Onsite
Claims 112Onsite & Virtual
Underwriting235Onsite & Virtual
Operations022Virtual

 

Any assistance will be greatly appreciated

1 ACCEPTED SOLUTION

Hi @Jadegirlify - Yes you can create it by using below measures and display the output in table chart from same original table.

 

Measure for Onsite Count:

Onsite Count =
CALCULATE(
COUNT('OriginalTable'[Work Location]),
'OriginalTable'[Work Location] = "Onsite"
) +0

 

Measure for Virtual Count:

 

Virtual Count =
CALCULATE(
    COUNT('DWLP'[Work Location]),
    'DWLP'[Work Location] = "Virtual"
)+0
 
 Measure for Total Onsite/Virtual:
 
Total Onsite/Virtual = [Onsite Count] + [Virtual Count]
 
Measure for Work Location Type:
 
Work Location Type =
SWITCH(
    TRUE(),
    [Onsite Count] = 0 && [Virtual Count] > 0, "Virtual",
    [Onsite Count] > 0 && [Virtual Count] = 0, "Onsite",
    [Onsite Count] > 0 && [Virtual Count] > 0, "Onsite & Virtual"
)
 
 
rajendraongole1_0-1718335968486.png

 

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

7 REPLIES 7
Jadegirlify
Helper I
Helper I

@rajendraongole1 Thanks it worked. Is there a way to achieve these calculations in the original table without creating a calculated table? I am unable to connect it to the original table and I need a bunch of filters from the original table.

Hi @Jadegirlify - Yes you can create it by using below measures and display the output in table chart from same original table.

 

Measure for Onsite Count:

Onsite Count =
CALCULATE(
COUNT('OriginalTable'[Work Location]),
'OriginalTable'[Work Location] = "Onsite"
) +0

 

Measure for Virtual Count:

 

Virtual Count =
CALCULATE(
    COUNT('DWLP'[Work Location]),
    'DWLP'[Work Location] = "Virtual"
)+0
 
 Measure for Total Onsite/Virtual:
 
Total Onsite/Virtual = [Onsite Count] + [Virtual Count]
 
Measure for Work Location Type:
 
Work Location Type =
SWITCH(
    TRUE(),
    [Onsite Count] = 0 && [Virtual Count] > 0, "Virtual",
    [Onsite Count] > 0 && [Virtual Count] = 0, "Onsite",
    [Onsite Count] > 0 && [Virtual Count] > 0, "Onsite & Virtual"
)
 
 
rajendraongole1_0-1718335968486.png

 

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





@rajendraongole1 Also with the same table, I would like to have this output table:

Original Table

DepartmentWork Location
HROnsite
HROnsite
HROnsite
HROnsite
Claims Onsite
Claims Virtual
UnderwritingOnsite
UnderwritingOnsite
UnderwritingVirtual
UnderwritingVirtual
UnderwritingVirtual
OperationsVirtual
OperationsVirtual

 

Result Table (Total HR count is 4 and all 4 are onsite, that's why virtual is 0 etc)

DepartmentTotal DepartmentWork LocationOnsiteVirtualTotal
HR13Onsite404
HR13Onsite404
HR13Onsite404
HR13Onsite404
Claims 13Onsite102
Claims 13Virtual012
Underwriting13Onsite205
Underwriting13Onsite205
Underwriting13Virtual035
Underwriting13Virtual035
Underwriting13Virtual035
Operations13Virtual022
Operations13Virtual022

@rajendraongole1 Do you happen to had a mesure to obtain the follow columns above: Total Department, Onsite, Virtual and Total.

@rajendraongole1 That worked! Thanks so much for the prompt response.

@Jadegirlify Thanks for confirming and Happy to Help!!

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





rajendraongole1
Super User
Super User

Hi @Jadegirlify - Create a calculated Table 

Output =
SUMMARIZE(
    'DWLP',
    'DWLP'[Department],
    "Onsite", CALCULATE(COUNTROWS('DWLP'), 'DWLP'[Work Location] = "Onsite"),
    "Virtual", CALCULATE(COUNTROWS('DWLP'), 'DWLP'[Work Location] = "Virtual")
)

 

rajendraongole1_0-1718331211457.png

 

 

create two calculated columns , one for to calculate Total Online/Virtual and another worklocation using switch statements.

Total Onsite/Virtual = [Onsite] + [Virtual]
 
another calculated Column:
Work Location Type =
SWITCH(
    TRUE(),
    [Onsite] = 0 && [Virtual] > 0, "Virtual",
    [Onsite] > 0 && [Virtual] = 0, "Onsite",
    [Onsite] > 0 && [Virtual] > 0, "Onsite & Virtual"
)
 
Try the above logic and let know
 
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors