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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MPetramalo214
Helper I
Helper I

Creating a Measure to Get Max Value of a Measure

Hi everyone, I am trying to reference a line charts maximum value in a second measure for a different visual.

 

MPetramalo214_0-1642093164561.png


Is my line chart, the x-axis is date, and the y-axis is a measure that calculates actual occupancy of a hotel. (The measure is simply a distinct count of all reservations and its assigned room).

 

I need to write a measure that will look at all the dates we're filtering for, and determine what the maximum value.  The problem I'm running into is that MAX has to reference a column, not a measure; and MAXX is returning a value greater than the peak on the line chart. 

1 ACCEPTED SOLUTION

In that case try this:

Max Actual Occupancy =

CALCULATE (

MAXX(

DISTINCT('Calendar'[Date]),

        [Actual Occupancy]),

         ALLSELECTED ('Calendar'))

 



Did I answer your question? Mark my post as a solution!


https://allure-analytics.com/
https://www.youtube.com/channel/UCndD_QZVNB_JWYLEmP6KrpA
https://www.linkedin.com/company/77757292/

Proud to be a Super User!




View solution in original post

5 REPLIES 5
ALLUREAN
Solution Sage
Solution Sage

Hi, @MPetramalo214 

 

Let suppose you measure in visual is [HotelOccupancy].

 

Create new measure like:

 

MaxHotelOccupancy = 

VAR MaxDate = MAX('Datetable'[Date])

RETURN

CALCULATE([HotelOccupancy],
FILTER(ALL('Datetable'),
'Datetable'[Date] = MaxDate ))

 

 




Did I answer your question? Mark my post as a solution!


https://allure-analytics.com/
https://www.youtube.com/channel/UCndD_QZVNB_JWYLEmP6KrpA
https://www.linkedin.com/company/77757292/

Proud to be a Super User!




Max Actual Occupancy = 
var maxDate = MAX('Calendar'[Date])
return
    CALCULATE(
        [Actual Occupancy], 
        'Calendar'[Date] = maxDate
    )

 

I tried the above measure, and its returning the same value as actual occupancy for each day

MPetramalo214_0-1642095533358.png

In that case try this:

Max Actual Occupancy =

CALCULATE (

MAXX(

DISTINCT('Calendar'[Date]),

        [Actual Occupancy]),

         ALLSELECTED ('Calendar'))

 



Did I answer your question? Mark my post as a solution!


https://allure-analytics.com/
https://www.youtube.com/channel/UCndD_QZVNB_JWYLEmP6KrpA
https://www.linkedin.com/company/77757292/

Proud to be a Super User!




Very cool! Works perfectly as intended - I was also able to accomplish this with another measure

var __table = SUMMARIZE('Calendar','Calendar'[Date], "_-value", _Measures[Actual Occupancy])
return MAXX(__table, [_-value])

but your solution works in the exact format I needed it to! 

 

Thanks again!

I remeber that use can use also analytics tab in line chart options to set max sales line.

max line chart.png

 

 

 

https://allure-analytics.com/

https://www.youtube.com/channel/UCndD_QZVNB_JWYLEmP6KrpA

https://www.linkedin.com/company/77757292/




Did I answer your question? Mark my post as a solution!


https://allure-analytics.com/
https://www.youtube.com/channel/UCndD_QZVNB_JWYLEmP6KrpA
https://www.linkedin.com/company/77757292/

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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