Forum Discussion
Can i count values within a measure?
- Anonymous7 years ago
Hi PaulHallam ,
Please create a table with decimal value of range start and end, then you can use following measure to summarize and look correspond records and get count of them.
Measure formula:
Summary Count = VAR temp = SUMMARIZE ( 'Sample', [Sensor Number], "Count", [Occupied Days], "Percent", [Occupied %] ) RETURN COUNTROWS ( FILTER ( temp, [Percent] >= MAX ( T4[Start] ) && [Percent] <= MAX ( T4[End] ) ) ) + 0Regards,
Xiaoxin Sheng
Hi PaulHallam ,
I'd like to suggest you do unpivot columns on your time fields to convert them to time attribute and value.
Then you can write condition based on time value instead hard code all time fields and compare with different time fields.
BTW, you can't direct aggregate with measure result. Since measure result are dynamic calculated based on its row contents. So you need to create variable summarized table to restore scenario, then you can do aggregate with this summary table.
Measure Totals, The Final Word
Regards,
Xiaoxin Sheng
- PaulHallam7 years ago
Helper III
Thanks for the advice Xiaoxin. I had already tried this and got as far as the following table 'SUMMARY' but then got stuck;
Date Sensor Occupied for Day 01/01/2019 S1 1 01/01/2019 S2 1 01/01/2019 S3 1 01/01/2019 S4 1 01/01/2019 S5 1 02/01/2019 S1 1 02/01/2019 S2 1 02/01/2019 S3 1 02/01/2019 S4 0 02/01/2019 S5 1 03/01/2019 S1 0 03/01/2019 S2 0 …. …. …. In the above table sensor 1 was used on 2 out of 3 days, and i can easily calculate individual percentage use in a measure.
% Use = 'SUMMARY' [Occupied for day]/DISTINCTCOUNT('SUMMARY'[Date])
I need a measure to tell me the number of sensors that are in the ranges 0%-20%, 20%-40%, 40%-60%, 60%-80% and 80%-100%.
I am assuming i have to add a table with the ranges in but cant seem to work it out
Any thoughts, i am pretty new to Power BI so please explain logic for a solution in detail if possible,
Thanks Paul- Anonymous7 years agoNot applicable
Hi PaulHallam ,
Can you please share some sample data for test? Please do mask on sensitive data before share.
Regards,
Xiaoxin Sheng
- PaulHallam7 years ago
Helper III
Hi Xiaoxin,
The 'DATA' table below contains data for 5 sensors over 6 daysDate 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. This table works with the date slicer on the report
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 that also works with the date slicer, 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