I have a list of values, with several entries per day, spanning several days. I'd like, for each day, to get the max, min and the last values. I'm using additional column as I didn't find a way to use a measure.
Here is a sample of data:
date | marge | date (Day) |
---|---|---|
2/1/2021 9:31 | 832,95 | 01-févr |
2/1/2021 9:54 | 670,95 | 01-févr |
2/1/2021 10:15 | 815,65 | 01-févr |
2/1/2021 10:36 | 890,65 | 01-févr |
2/1/2021 10:57 | 836,9 | 01-févr |
2/1/2021 11:18 | 912,4 | 01-févr |
2/1/2021 11:40 | 1149,25 | 01-févr |
2/1/2021 12:01 | 1339,15 | 01-févr |
2/1/2021 12:22 | 1449,3 | 01-févr |
2/1/2021 12:43 | 1659,2 | 01-févr |
2/1/2021 13:04 | 1502,6 | 01-févr |
2/1/2021 13:25 | 1357,3 | 01-févr |
2/1/2021 13:46 | 1508,85 | 01-févr |
2/1/2021 14:07 | 1427,65 | 01-févr |
2/1/2021 14:29 | 1408,05 | 01-févr |
2/1/2021 14:50 | 1421,1 | 01-févr |
2/1/2021 15:37 | 1398,85 | 01-févr |
2/1/2021 15:51 | 1410,85 | 01-févr |
2/1/2021 16:11 | 1089,2 | 01-févr |
2/1/2021 16:32 | 1130,55 | 01-févr |
2/1/2021 16:54 | 1111,45 | 01-févr |
2/1/2021 17:15 | 1134,9 | 01-févr |
2/1/2021 17:36 | 1274,85 | 01-févr |
2/1/2021 17:57 | 1384,75 | 01-févr |
2/1/2021 18:18 | 1384,75 | 01-févr |
2/2/2021 10:23 | 761,2 | 02-févr |
2/2/2021 10:44 | 955,55 | 02-févr |
2/2/2021 12:58 | 622,85 | 02-févr |
2/2/2021 13:17 | 668,9 | 02-févr |
2/2/2021 15:16 | 754,1 | 02-févr |
2/2/2021 16:32 | 735,7 | 02-févr |
2/2/2021 16:45 | 722,25 | 02-févr |
2/2/2021 17:05 | 693,15 | 02-févr |
2/2/2021 17:26 | 699,05 | 02-févr |
2/2/2021 17:48 | 644,6 | 02-févr |
2/2/2021 18:09 | 594,9 | 02-févr |
2/2/2021 18:30 | 594,9 | 02-févr |
2/3/2021 10:56 | 513,65 | 03-févr |
2/3/2021 11:15 | 468,65 | 03-févr |
2/3/2021 11:35 | 518,25 | 03-févr |
2/3/2021 11:56 | 643 | 03-févr |
2/3/2021 12:16 | 584 | 03-févr |
2/3/2021 12:36 | 656,75 | 03-févr |
2/3/2021 12:56 | 685,85 | 03-févr |
2/3/2021 13:16 | 773,7 | 03-févr |
2/3/2021 13:36 | 755,15 | 03-févr |
2/3/2021 13:56 | 608,95 | 03-févr |
2/3/2021 14:16 | 622,6 | 03-févr |
2/3/2021 14:36 | 580,5 | 03-févr |
2/3/2021 14:56 | 591,1 | 03-févr |
2/3/2021 15:30 | 513,35 | 03-févr |
2/3/2021 16:56 | 354,95 | 03-févr |
2/3/2021 17:30 | 630,05 | 03-févr |
2/3/2021 17:58 | 625,2 | 03-févr |
2/4/2021 9:38 | 524,2 | 04-févr |
2/4/2021 10:04 | 603,9 | 04-févr |
2/4/2021 10:24 | 668,2 | 04-févr |
2/4/2021 11:05 | 612,7 | 04-févr |
2/4/2021 11:28 | 654,45 | 04-févr |
So for the min and max, I have the following formulae:
CALCULATE(MAX(intradays[marge]); FILTER(intradays; intradays[date (Day)]=EARLIER(intradays[date (Day)]))
which works correctly (MIN for min)
However, to get the last for each day is a completely different story. I have no idea how to achieve this.
The values I'm looking for are:
Last for the 1st of Feb : 1384.75
Last for the 2nd : 595.9
Last for the 3rd : 652.2
P.S.: using 365.
Since you are using a model consisting of a single table (and no dimensions) you must take care of the filtering columns involved.
This is a measure that first finds the max date keeping the filter over intradays[date (Day)] and then finds the corresponding Marge, filtering only the intradays[date] column.
The MAX is used to avoid an error in case there were two identical timestamps.
LastMarge =
VAR maxDate =
CALCULATE (
MAX ( intradays[date] ),
ALLEXCEPT ( intradays, intradays[date (Day)] )
)
RETURN
CALCULATE (
MAX ( 'intradays'[marge] ),
intradays[date] = maxDate,
REMOVEFILTERS ( intradays )
)
The column can be created using the measure, like for instance
LastMargin = [LastMarge]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments