Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
barakm
Frequent Visitor

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 ? 

 

 

1 ACCEPTED SOLUTION
qqqqqwwwweeerrr
Super User
Super User

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
    )
 
qqqqqwwwweeerrr_0-1723561163885.png

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

View solution in original post

3 REPLIES 3
barakm
Frequent Visitor

My bad, it works , thanks a lot

qqqqqwwwweeerrr
Super User
Super User

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
    )
 
qqqqqwwwweeerrr_0-1723561163885.png

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_0-1723562166433.png

 

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

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.