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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Return the Date or Day in corresponding column using a measure that finds the max value in a column

Hello, we are trying to return the Date or the Day (or both) to be used in a Card. We have found the Max Status Value but can't get the calculation to return the corresponding Date or, ideally, the Day (Tuesday).

 

Here is the measure that returns the maximum value in the table within the [StatusAdj1] measure column.

 

Test =

VAR MaxUtil = MAXX(ALLSELECTED(FCT_SpaceOccupancyStatusHourQtrPots[Date]),[StatusAdj1])

 

// VAR Check = [StatusAdj1] = MaxUtil

Return MaxUtil

 

Ideally, we would like to return a card with the date, in this case it would be 10 May 2022 and another Card with the Day for that Date = Tuesday.

 

 

 

Table.png

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can create a couple of measures like

Date of Max =
SELECTCOLUMNS (
    TOPN (
        1,
        ALLSELECTED ( FCT_SpaceOccupancyStatusHourQtrPots[Date] ),
        [StatusAdj1], DESC,
        FCT_SpaceOccupancyStatusHourQtrPots[Date], ASC
    ),
    "@val", FCT_SpaceOccupancyStatusHourQtrPots[Date]
)

Day of Max = FORMAT( [Date of Max], "dddd")

In the event of 2 dates having the same max value this will return the earliest. If you want the latest instead just change ASC to DESC

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

John, that worked straight out the box.

 

Thank you.

johnt75
Super User
Super User

You can create a couple of measures like

Date of Max =
SELECTCOLUMNS (
    TOPN (
        1,
        ALLSELECTED ( FCT_SpaceOccupancyStatusHourQtrPots[Date] ),
        [StatusAdj1], DESC,
        FCT_SpaceOccupancyStatusHourQtrPots[Date], ASC
    ),
    "@val", FCT_SpaceOccupancyStatusHourQtrPots[Date]
)

Day of Max = FORMAT( [Date of Max], "dddd")

In the event of 2 dates having the same max value this will return the earliest. If you want the latest instead just change ASC to DESC

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.