Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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])
Solved! Go to Solution.
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.
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.
@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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
73 | |
58 | |
36 | |
32 |
User | Count |
---|---|
90 | |
62 | |
61 | |
49 | |
45 |