'Categorizing times into buckets using PowerBI

I have a list of locations (100 locations) that received a time stamp every day for a month. I have 3 months worth of data so each location shows in my table in 90 rows each (1 row per day). The time stamp is the last time a transaction took place prior to the store close time. I have a column that shows the average of the location's last transactions time stamps. I'm trying to now create buckets of time frames. For example bucket 1 = <2 hours, bucket 2 = 2-4 hours, bucket 3 = >4 hrs. I want to be able to show how many locations fall into each bucket. This is what I can't figure out. Any suggestions would be greatly appreciated. Thank you



Solution 1:[1]

You are trying to access a mythic property on your JSON object, but your data does not have such a property. I would recommend that you study more on JSON structure and accessing properties in javascript.

Basically, json.mythics checks for a property called mythics in the root level of your json object, the same way json.moments does. If your data was organized like:

{
  "moments": [...],
  "mythics": [...]
}

then you would access it with json.mythics


But your json only has a moments array of objects, some of which have a rarity property set to "mythic".

Assuming you want to filter out these elements from the array, a simple filter should suffice:

const mythics = json.moments.filter(moment => moment.rarity === 'mythic');
mythics.length // gives the length of the 'mythics'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 skara9