Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am trying to create a new measure for the below scenario.
1) I want to count the number of people that are inside a building .
Formula I used
PeopleInside = CALCULATE(DISTINCTCOUNT(Table[person_id]),isblank(Table[exit_time]))
This works perfect.
2) I want to distinct count the number of people that left the building.
Formula I used
PeopleOutside = CALCULATE(DISTINCTCOUNT(Table[person_id]),Table[exit_time] <> BLANK())
Here comes the problem :
person_id | person_name | enter_time | exit_time |
100 | xyz | 04/06/2018 9:46:41 AM | 04/06/2018 6:08:13 PM |
100 | xyz | 04/06/2018 6:30:11 PM |
In this case, PeopleOutside should be showing 0 because the person is inside the building but my formula shows 1 for both PeopleInside and PeopleOutside.
Could someone please help. Thanks!
Solved! Go to Solution.
Hi @SR1,
We can filter out these person still inside. Try this formula, please.
Measure = VAR stillIn = CALCULATETABLE ( VALUES ( Table1[person_id] ), ISBLANK ( 'Table1'[exit_time] ) ) RETURN CALCULATE ( DISTINCTCOUNT ( Table1[person_id] ), FILTER ( 'Table1', ISBLANK ( 'Table1'[exit_time] ) = FALSE () && NOT Table1[person_id] IN stillIn ) )
Best Regards,
Dale
Hi @SR1,
Did it work?
Best Regards,
Dale
Hi @SR1,
We can filter out these person still inside. Try this formula, please.
Measure = VAR stillIn = CALCULATETABLE ( VALUES ( Table1[person_id] ), ISBLANK ( 'Table1'[exit_time] ) ) RETURN CALCULATE ( DISTINCTCOUNT ( Table1[person_id] ), FILTER ( 'Table1', ISBLANK ( 'Table1'[exit_time] ) = FALSE () && NOT Table1[person_id] IN stillIn ) )
Best Regards,
Dale
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
96 | |
77 | |
66 | |
53 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |