Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have the following type of dataset:
Date | ID | Copies sold |
01.01.2020 | 1 | 200 |
01.01.2020 | 1 | 100 |
05.01.2020 | 2 | 500 |
06.01.2020 | 3 | 5 |
07.01.2020 | 3 | 5 |
08.01.2020 | 3 | 5 |
09.01.2020 | 4 | 100 |
09.01.2020 | 4 | 50 |
I have a Bar Chart and want to count number of ID's based on copies sold in interval 0-99, 100-499, 500+.
Thank you!
You can build a dimension in the front end, but a better way is to do an interval match. Apart from being fster, it salso easier to maintain (for example, changing the bands). Follow this code pattern (adapt to your specific case):
Intervals:
LOAD * Inline
[
From, To, BandName
0, 99, 0-99
100, 499, 100-499
500, 1E6, 500+
];
Left Join (Fact)
IntervalMatch([Copies Sold])
LOAD From, To
Resident Intervals;
// OPTIONAL
Left Join (Fact)
LOAD *
Resident Intervals;
Drop Table Intervals;
The "OPTIONAL" code is not essential, although I prefer to clean up my data model, which that code does.