Forum Discussion
Count values assigned into a range inside a measure
Hi All,
I have a table 'DATA' as below;
| Date | Sensor Number | Occupied |
| 01/01/2019 | Sensor 1 | 1 |
| 01/01/2019 | Sensor 2 | 0 |
| 01/01/2019 | Sensor 3 | 1 |
| 01/01/2019 | Sensor 4 | 0 |
| 01/01/2019 | Sensor 5 | 1 |
| 02/01/2019 | Sensor 1 | 0 |
| 02/01/2019 | Sensor 2 | 0 |
| 02/01/2019 | Sensor 3 | 0 |
| 02/01/2019 | Sensor 4 | 0 |
| 02/01/2019 | Sensor 5 | 1 |
| 03/01/2019 | Sensor 1 | 1 |
| 03/01/2019 | Sensor 2 | 1 |
| 03/01/2019 | Sensor 3 | 0 |
| 03/01/2019 | Sensor 4 | 0 |
| 03/01/2019 | Sensor 5 | 1 |
| 04/01/2019 | Sensor 1 | 0 |
| 04/01/2019 | Sensor 2 | 1 |
| 04/01/2019 | Sensor 3 | 0 |
| 04/01/2019 | Sensor 4 | 1 |
| 04/01/2019 | Sensor 5 | 1 |
| 05/01/2019 | Sensor 1 | 0 |
| 05/01/2019 | Sensor 2 | 1 |
| 05/01/2019 | Sensor 3 | 0 |
| 05/01/2019 | Sensor 4 | 1 |
| 05/01/2019 | Sensor 5 | 0 |
| 06/01/2019 | Sensor 1 | 0 |
| 06/01/2019 | Sensor 2 | 1 |
| 06/01/2019 | Sensor 3 | 0 |
| 06/01/2019 | Sensor 4 | 1 |
| 06/01/2019 | Sensor 5 | 0 |
I have two measures;
Occupied Days = SUM('DATA' [Occupied])
Occupied % = DATA[Occupied Days]/DISTINCTCOUNT('DATA' [Date])
From these i can produce a table as below;
| Sensor Number | Occupied Days | Occupied % |
| Sensor 1 | 2 | 33.33% |
| Sensor 2 | 4 | 66.67% |
| Sensor 3 | 1 | 16.67% |
| Sensor 4 | 3 | 50.00% |
| Sensor 5 | 4 | 66.67% |
What i am trying to do is generate the table below, but i can't seem to get close and i cant find any solutions in the forum. Please help if possible.
| Range | Count |
| 0%-20% | 1 |
| 20%-40% | 1 |
| 40%-60% | 1 |
| 60%-80% | 2 |
| 80%-100% | 0 |
Thanks for any pointers in the right direction.
- Anonymous7 years ago
That's more involved. Check out this link:
3 Replies
- AnonymousNot applicable
Maybe this can help?
First, created a range table with min, max and a lable to use. Called RangeTable
Added a calculated column to your original table that will bring in that range label
Range = CALCULATE( VALUES(RangeTable[Range Label]), FILTER( RangeTable, Table1[Occupied %] >= RangeTable[Min] && Table1[Occupied %] < RangeTable[Max] ) )Then depending on what your end goal is, you can create a summarized table or use the code in a measure for a virtual table
Table = ADDCOLUMNS( SUMMARIZE( Table1, Table1[Range]),"Count", CALCULATE( COUNTROWS(Table1)))
- PaulHallam
Helper III
Thanks for the suggestion Nick, i think what you have done is perfect for a static selection of dates. The problem is i have a date slicer on the report page and i need the table visualisation to update on the dates selected.
- AnonymousNot applicable
That's more involved. Check out this link: