Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

min and max data point highlights

Hi, 

I was trying to highlight only min and max data labels in the line chart. 

I have used date column which is of this format

01-01-2024

,start time 

10.00.00 AM

, End time 

11.00.00 AM

 in the x axis and in y axis total apparent power and I have slicer for date, based on the slicer the line chart data is filtered.
i have created a DAX measure to highlight min and max data points but its not highlighting 

MaxValue =
VAR SelectedDate = SELECTEDVALUE('table'[Date])
RETURN
    CALCULATE(
        MAX('Table'[Total_Apparent_Power]),
        FILTER(
            ALL('table'),
            'table'[Date] = SelectedDate
        )
    )
MaxLabel = IF(MAX('table'[Total_Apparent_Power]) = [MaxValue], MAX('table'[Total_Apparent_Power]), BLANK())

so there is lots of data point is highlighted, for one date there will be lots of total apparent since data is captured every one hour. Can any one help to provide Perfect DAX measure to highlight max total apparent power dynamically based on the filter applied by the slicer.

  • Hi Anonymous 

     

    If I have 4.3, 4.4 and 4.5 (the max) in my data set, 4.5 is highlighted as the max value, please check my example PBIX file.  So for your numbers it should also work.

     

     

     

    If the same isn't happening for you then either your data is somehow diferent or more likely the DAX measure isn't working as expected.  Either way I'd need to see the data you are using to figure out why.

     

    Can you post your data here, or better still, link to your PBIX file?

     

    Regards

     

    Phil

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

     

    Maybe you can try this alternative workaround:

    First of all, I create a set of sample:

    Then add a Line and clustered column chart in report view:

    Next, add a measure:

    MEASURE =
    VAR _maxValue =
        CALCULATE ( MAX ( 'Table'[Total_Apparent_Power] ), ALLSELECTED ( 'Table' ) )
    VAR _minValue =
        CALCULATE ( MIN ( 'Table'[Total_Apparent_Power] ), ALLSELECTED ( 'Table' ) )
    RETURN
        IF (
            MAX ( 'Table'[Total_Apparent_Power] ) = _maxValue,
            _maxValue,
            IF ( MAX ( 'Table'[Total_Apparent_Power] ) = _minValue, _minValue )
        )
    

    And put it in the Column y-axis field, the result is as follow:

     

    Best Regards

    Zhengdong Xu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Hi Anonymous 

     

    Download PBIX file with example below

     

    How do you wish to highlight the min and max points?  You could chnage the color of the label (value) with this measure and using it as the conditional formatting rule for the label color

     

     

     

    Max_TAP_CF = 
    
    VAR _max = CALCULATE(MAX('DataTable'[Total_Apparent_Power]), FILTER(ALL('DataTable'), SELECTEDVALUE('DataTable'[Date]) = 'DataTable'[Date]))
    
    VAR _min = CALCULATE(MIN('DataTable'[Total_Apparent_Power]), FILTER(ALL('DataTable'), SELECTEDVALUE('DataTable'[Date]) = 'DataTable'[Date]))
    
    VAR _point = SELECTEDVALUE('DataTable'[Total_Apparent_Power])
    
    RETURN
    
    IF(_point = _max, "orange", IF( _point = _min, "green", "white"))

     

     

     

    which gives this

     

     

    As I've chosen to color all other labels/values white they do not appear.  You can show these of course if you wish be leaving them the default black color.

     

    Regards

     

    Phil

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi PhilipTreacy, 
      I have tried using this measure but it's not highlight single max value instead if the line chart has data points of  4.5,4.4,4.3 then all the data points are highlighted instead of one

       

      • PhilipTreacy's avatar
        PhilipTreacy
        Icon for Super User rankSuper User

        Hi Anonymous 

         

        If I have 4.3, 4.4 and 4.5 (the max) in my data set, 4.5 is highlighted as the max value, please check my example PBIX file.  So for your numbers it should also work.

         

         

         

        If the same isn't happening for you then either your data is somehow diferent or more likely the DAX measure isn't working as expected.  Either way I'd need to see the data you are using to figure out why.

         

        Can you post your data here, or better still, link to your PBIX file?

         

        Regards

         

        Phil