Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Conditionally Format lines on a line graph

Hi, I would like to conditionally format my lines in the below line graph using year in DAX. The logic that I want is if year= 2019-2020, I would like the lines to be shown as dashed (--) instead of solid lines.

This is an example of my data

Year

Agency

Organization

Values

2017

agency1

orga

50

2018

agency2

orgb

65

2019

agency3

orgc

47

2020

agency4

orgd

84

2021

agency5

orge

55

2022

agency6

orgf

67

 

 

I have done something similar with a bar chart - but I would like this dax code to be general; not column specific with the ability to be dynamic with filter input.

 

year2022 = IF('Data'[Year]=2022, 'Data'[Year] & " " & 'Data'[columnname],’Data'[columnname])

  • Hi Anonymous ,

     

    Maybe this is the result you want:

    Please try following DAX:

    Measure = CALCULATE(SUM('Table'[Values]),FILTER('Table','Table'[Year] IN {2019,2020}))

     

    Put the [measure] and [Value]  into Y-axis:

     

    Change line type of measure into dashed:

    Best regards,

    Yadong Fang

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

     

2 Replies

  • Anonymous , Create a measure for 2019-2020

     

    example

     

    calculate(Sum(’Data'[columnname]), Filter('Data','Data'[Year] in {2019,2022}))

     

    use this measure in line visual, enable marked, and under shape choose marker shape _ and make line width 0

  • v-yadongf-msft's avatar
    v-yadongf-msft
    Community Support

    Hi Anonymous ,

     

    Maybe this is the result you want:

    Please try following DAX:

    Measure = CALCULATE(SUM('Table'[Values]),FILTER('Table','Table'[Year] IN {2019,2020}))

     

    Put the [measure] and [Value]  into Y-axis:

     

    Change line type of measure into dashed:

    Best regards,

    Yadong Fang

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