Forum Discussion

aileenkaz's avatar
aileenkaz
Frequent Visitor
1 year ago
Solved

Dynamic Y-axis range in Line chart

Hello!

I have four line charts shown next to each other. They contain the same data F_merged[Value] but there us a filter used on each of them.

I need to have the same Y-axis range for all four charts. If all of them are showing values less than 50, the range should go from 0 to 50. If at least one of them is showing value greater than 50, ranges for all four charts should go from 0 to 100.

 

I am using measure to set the Maximum for Y-axis (based on find the highest value among those plotted in the chart:

F_YMax = IF(MAX(F_merged[Value]) = 0, 50, IF(CEILING(MAX(F_merged[Value]),10)<60,CEILING(MAX(F_merged[Value]),50),100))
(yes, it probably could be written more simply, but nevermind, this works - it changes between 50 and 100 accordingly)
 
However, even if F_YMax is 100, there are some cases when the range of Y-axis is not changed to 0-100.
Can anyone explain why is this happening?
 
Thanks a lot!
 
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi aileenkaz , hello parry2k, thank you for your prompt reply!

     

    Please try the following measure:

    ValueMeasure = MAX('Table'[Value])

     

    F_YMax = 
     IF(
            MAXX(ALL('Table'), 'Table'[ValueMeasure]) = 0, 
            50, 
            IF(
                CEILING(MAXX(ALL('Table'), 'Table'[ValueMeasure]), 10) < 60, 
                CEILING(MAXX(ALL('Table'), 'Table'[ValueMeasure]), 50), 
                100
            )
        )

     

     Result:

     

     

     

    Best regards,

    Joyce

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

6 Replies

  • aileenkaz hard to tell but try this:

     

    F_YMax = I
    VAR __Max = CALCULATE ( MAX(F_merged[Value]), ALLSELECTED () )
    RETURN
    IF ( __Max = 0, 50, 
        IF ( CEILING (__Max, 10 ) < 60, CEILING ( __Max, 50 ), 100 )
    )
    • aileenkaz's avatar
      aileenkaz
      Frequent Visitor

      I tried, but the result is the same 😞

      It seems the value of F_YMax is calculated for each graph separately.

    • aileenkaz's avatar
      aileenkaz
      Frequent Visitor

      If I use ALL, F_YMax is always 100 (even if all plotted values in the four graphs are less than 50).

  • aileenkaz that makes sense. Let me ask you this. Do all these visuals have filters from the common tables? What does the data model look like? Can you share a sample pbix file?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi aileenkaz , hello parry2k, thank you for your prompt reply!

     

    Please try the following measure:

    ValueMeasure = MAX('Table'[Value])

     

    F_YMax = 
     IF(
            MAXX(ALL('Table'), 'Table'[ValueMeasure]) = 0, 
            50, 
            IF(
                CEILING(MAXX(ALL('Table'), 'Table'[ValueMeasure]), 10) < 60, 
                CEILING(MAXX(ALL('Table'), 'Table'[ValueMeasure]), 50), 
                100
            )
        )

     

     Result:

     

     

     

    Best regards,

    Joyce

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