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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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