Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join 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.

Reply
Anonymous
Not applicable

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])

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Maybe this is the result you want:

vyadongfmsft_0-1664504643236.png

Please try following DAX:

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

 

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

vyadongfmsft_2-1664504892772.png

 

Change line type of measure into dashed:

vyadongfmsft_3-1664504940896.png

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.

 

View solution in original post

2 REPLIES 2
v-yadongf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Maybe this is the result you want:

vyadongfmsft_0-1664504643236.png

Please try following DAX:

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

 

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

vyadongfmsft_2-1664504892772.png

 

Change line type of measure into dashed:

vyadongfmsft_3-1664504940896.png

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.

 

amitchandak
Super User
Super User

@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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.