Forum Discussion

barakm's avatar
barakm
Frequent Visitor
2 years ago
Solved

last date not shown correctly

Hello Dear Team,

Got an issue with displaying the last date

I have a table with startTime endTime and WeekRange 

startTime        endTime
2024-07-02    2024-07-09
2024-07-09    2024-07-16
2024-07-16    2024-07-23
2024-07-23    2024-07-30
2024-07-30    2024-08-06
2024-08-06    2024-08-13

and I have added new column named WeekRange to show a Week Range in this format:
06-08-2024 to 13-08-2024
02-07-2024 to 09-07-2024
30-07-2024 to 06-08-2024

WeekRange =
FORMAT([startTime].[Date], "DD-MM-YYYY") & " to " & FORMAT([endTime].[Date], "DD-MM-YYYY")

 

 

Now I want to show in a Card visual only the last week range,
On visualizations, when selecting in the Fields Last WeekRange it shows the 30-07-2024 to 06-08-2024 but not the correct one   06-08-2024 to 13-08-2024

Do you know how do I fix this ? 

 

 

  • Max Range =
    VAR MaxStartDate =
        MAXX(ALL('Table'), 'Table'[startTime])
    VAR MaxEndDate =
        MAXX(
            FILTER(
                ALL('Table'),
                'Table'[startTime] = MaxStartDate
            ),
            'Table'[endTime]
        )
    VAR RangeValue =
        CALCULATE(
            VALUES('Table'[week_range]),
            'Table'[startTime] = MaxStartDate &&
            'Table'[endTime] = MaxEndDate
        )
    RETURN
        IF(
            ISBLANK(RangeValue),
            BLANK(),
            RangeValue
        )
     

    I am getting this can you please check, if this works

     

    Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
    Check for more intersing solution here: www.youtube.com/@Howtosolveprobem

    Regards

3 Replies

  • Max Range =
    VAR MaxStartDate =
        MAXX(ALL('Table'), 'Table'[startTime])
    VAR MaxEndDate =
        MAXX(
            FILTER(
                ALL('Table'),
                'Table'[startTime] = MaxStartDate
            ),
            'Table'[endTime]
        )
    VAR RangeValue =
        CALCULATE(
            VALUES('Table'[week_range]),
            'Table'[startTime] = MaxStartDate &&
            'Table'[endTime] = MaxEndDate
        )
    RETURN
        IF(
            ISBLANK(RangeValue),
            BLANK(),
            RangeValue
        )
     

    I am getting this can you please check, if this works

     

    Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
    Check for more intersing solution here: www.youtube.com/@Howtosolveprobem

    Regards

    • barakm's avatar
      barakm
      Frequent Visitor

       

      Thanks you for the try , I'm getting the following error in the visual when loading your DAX code