Get a value for the last entry of a day

Sebastien Chemouny

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.

sergiom

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get the last entry containing a certain value in Google Spreadsheet

From Dev

How to get unique column value and get the first entry and last entry from a cursor

From Dev

PostgreSQL: count number of occurrences of a value in a column using the last entry per day, per name

From Dev

Get the last Valid Value of day in a date using JQuery

From Dev

How to get value of the last day in the current month in awk

From Dev

Get last day of Month

From Dev

Used a for loop to create a certain number of entry boxes but can only .get last value from last entrybox

From Dev

Used a for loop to create a certain number of entry boxes but can only .get last value from last entrybox

From Java

How to get the last day of the month?

From Dev

Get last day of previous quarter

From Dev

Get first and last day of last month?

From Dev

How to get last day of current month and last day of next month

From Dev

Get the latest entry for a given day in Oracle

From Dev

Filter results by the Last Array Entry Field Value

From Dev

Filter results by the Last Array Entry Field Value

From Dev

Getting last entry for each of a distinct column value

From Dev

finding the first and last entry with a certain value in a row

From Dev

Selecting the last entry of each day in a timestamp and corresponding values

From Dev

how to get last 7 days record in mysql if no value in particular day return 0

From Dev

Get last entry from each user in database

From Dev

DateADD with codeigniter, to get the entry of the last 30 days

From Dev

How to get Last entry of Particular ID

From Dev

Get first and last entry given a timespan

From Dev

Get last return value

From Dev

Last entry from group by in select, replace null with last known value

From Dev

Get entry with max value in MySQL

From Dev

MySQL return last value per day

From Dev

MySQL return last value per day

From Dev

first and last value of a Day in Pandas (Python)

Related Related

  1. 1

    How to get the last entry containing a certain value in Google Spreadsheet

  2. 2

    How to get unique column value and get the first entry and last entry from a cursor

  3. 3

    PostgreSQL: count number of occurrences of a value in a column using the last entry per day, per name

  4. 4

    Get the last Valid Value of day in a date using JQuery

  5. 5

    How to get value of the last day in the current month in awk

  6. 6

    Get last day of Month

  7. 7

    Used a for loop to create a certain number of entry boxes but can only .get last value from last entrybox

  8. 8

    Used a for loop to create a certain number of entry boxes but can only .get last value from last entrybox

  9. 9

    How to get the last day of the month?

  10. 10

    Get last day of previous quarter

  11. 11

    Get first and last day of last month?

  12. 12

    How to get last day of current month and last day of next month

  13. 13

    Get the latest entry for a given day in Oracle

  14. 14

    Filter results by the Last Array Entry Field Value

  15. 15

    Filter results by the Last Array Entry Field Value

  16. 16

    Getting last entry for each of a distinct column value

  17. 17

    finding the first and last entry with a certain value in a row

  18. 18

    Selecting the last entry of each day in a timestamp and corresponding values

  19. 19

    how to get last 7 days record in mysql if no value in particular day return 0

  20. 20

    Get last entry from each user in database

  21. 21

    DateADD with codeigniter, to get the entry of the last 30 days

  22. 22

    How to get Last entry of Particular ID

  23. 23

    Get first and last entry given a timespan

  24. 24

    Get last return value

  25. 25

    Last entry from group by in select, replace null with last known value

  26. 26

    Get entry with max value in MySQL

  27. 27

    MySQL return last value per day

  28. 28

    MySQL return last value per day

  29. 29

    first and last value of a Day in Pandas (Python)

HotTag

Archive