Forum Discussion

MojoGene's avatar
MojoGene
Post Patron
2 years ago
Solved

Constant y-axis value based on field value?

I would like to show the high and low reference values as a line on a line chart along with the actual test value, but I struggling with how to approach the problem. The data table looks like this: ...
  • Ritaf1983's avatar
    Ritaf1983
    2 years ago

    Hi MojoGene 
    There is no option to work with your sample data file because all data is about the same point in time + the values are not equal to the values on the pictures....

     


    in general, you can add constant lines in this way :
    After creating a line graph :

    and then format it.
    Maximum line in the same way.

    These lines are dynamic:

    Pbix is attached.

    More guides about working with constant lines :

    https://www.easytweaks.com/add-horizontal-line-power-bi-chart-visual/

    https://blogs.perficient.com/2023/05/03/analytics-pane-in-power-bi-part1/

     

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

  • Ritaf1983's avatar
    Ritaf1983
    2 years ago

    Hi MojoGene 
    Now your sample has just one test ....if I understand correctly the table that you attached.

    So I used again my file.

    You can create customized constants. 
    Ob the first step you need to create dimensions for date and lab tests with unique values.

    These dimensions should be used as slicers and categories on the graph

    Then you can create measures for constants :

    sum_for_Max = if(SELECTEDVALUE('location_T'[Location],0)=0,"",
    CALCULATE(max(space_missions[Price]),ALLSELECTED('calendar'[Date])))
     
    sum_for_min = if(SELECTEDVALUE('location_T'[Location],0)=0,"",
    CALCULATE(min(space_missions[Price]),ALLSELECTED('calendar'[Date])))
     

    Result :

    PBIX is attached

    More information about dimension tables :

    https://radacad.com/basics-of-modeling-in-power-bi-what-is-a-dimension-table-and-why-say-no-to-a-single-big-table

     

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

     

  • Ritaf1983's avatar
    Ritaf1983
    2 years ago

    MojoGene 
    You need to work with both date and time dimensions hierarchically:

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

  • Ritaf1983's avatar
    Ritaf1983
    2 years ago

    Hi MojoGene 
    Glad to help.
    According to the problems with the granularity, please post it as a new question, and attach a pbix with the model that you created with enough data (not one day, one lab, etc...) and expected results.