cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
dw700d
Post Patron
Post Patron

calculate count when no value exsists

I have a table that shows a list of days all employees came into the office. If an employee enters the office on a specific date the “Badged in” Column has a Yes. My table does not show me data  when an employee does not come into the office. See the sample data below.

 

DateFull NameBadged InWorkCity
8-Dec-22ChadYesSan Antonio
7-Dec-22ChadYesSan Antonio
30-Nov-22ChadYesSan Antonio
29-Nov-22DanielYesATLANTA
22-Nov-22DanielYesATLANTA
17-Nov-22DanielYesATLANTA
15-Nov-22DianaYesSan Antonio
11-Nov-22DianaYesSan Antonio
9-Nov-22DianaYesSan Antonio
1-Nov-22GYesATLANTA
24-Feb-23GYesATLANTA
21-Feb-23GYesATLANTA

 

I wanted to create a measue that counts the amount of times an employee came into the office and if an employee has never come into the office the value would be 0. I connected the above table to an employee table with all employeees (this includes employees that have come to the office and those that have not). The measure is below

 

Entrance Count = CALCULATE(COUNT('Export'[Badged In]))+0

 

 It works fine with 1 column. as shown below

 

Full nameEntranceCount
Chad22
Daniel27
Diana21
G0
Derick30
Dave10
Cheryl21
Joseph24
Val

0

 

When I add two columns as shown below it does not work correctly. It creates multiple rows. For example chads WorkCity is located in Sanantonio and his entrance count correctly shows 22.  but becasue of the way my measure is constrcued it creates two addittional rows and adds a 0 since he has never badged into an Atlanta Workcity or Dallas workcity. How can I adjust my measure to be able to add multiple columns withouht creating addittional rows.

 

Full NameWorkCityEntranceCount
ChadATLANTA0
ChadDALLAS0
ChadSAN ANTONIO22
DanielATLANTA27
DanielDALLAS0
DanielSAN ANTONIO0
DianaATLANTA0
DianaDALLAS0
DianaSAN ANTONIO21
GATLANTA0
GDALLAS0
GSAN ANTONIO0
DerickATLANTA30
DerickDALLAS0
DerickSAN ANTONIO0

 

Desired output

 

Full NameWorkCityEntrance Count
ChadSAN ANTONIO22
DanielATLANTA27
DianaSAN ANTONIO21
GATLANTA0
DerickATLANTA30
1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @dw700d 

You can use if() to judge.

e.g 

IF(SELECTEDVALUE(City[WorkCity]) in VALUES('Export'[WorkCity]),CALCULATE(COUNT('Export'[Badged In])+0))

 

Best Regards!

Yolo Zhu

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

1 REPLY 1
v-xinruzhu-msft
Community Support
Community Support

Hi @dw700d 

You can use if() to judge.

e.g 

IF(SELECTEDVALUE(City[WorkCity]) in VALUES('Export'[WorkCity]),CALCULATE(COUNT('Export'[Badged In])+0))

 

Best Regards!

Yolo Zhu

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

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors