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
arjumandsheikh
Regular Visitor

changing the color of line chart

image.png

 

want a functionality like data upto the specific month selected on slicer should be represented by black line and that after specific month by red line 

1 ACCEPTED SOLUTION
tex628
Community Champion
Community Champion

Hi @arjumandsheikh

I'd say you want to create two measure that you use instead of one then. 

Measure before x = 
Var selecteddate = Date( YEAR(MAX('Calendar'[Date])) , SELECTEDVALUE( Table'[Your specific month]), 1 )
Return
Calculate( [Sales] ,  'Calendar'[Date] < selecteddate )

 

Measure after x = 
Var selecteddate = Date( YEAR(MAX('Calendar'[Date])) , SELECTEDVALUE( Table'[Your specific month]), 1 )
Return
Calculate( [Sales] ,  'Calendar'[Date] >= selecteddate )


Then apply the black color the the measure before x and red to the measure after x. 

Let me know how it goes! 

Br,
J


Connect on LinkedIn

View solution in original post

3 REPLIES 3
tex628
Community Champion
Community Champion

Hi @arjumandsheikh

I'd say you want to create two measure that you use instead of one then. 

Measure before x = 
Var selecteddate = Date( YEAR(MAX('Calendar'[Date])) , SELECTEDVALUE( Table'[Your specific month]), 1 )
Return
Calculate( [Sales] ,  'Calendar'[Date] < selecteddate )

 

Measure after x = 
Var selecteddate = Date( YEAR(MAX('Calendar'[Date])) , SELECTEDVALUE( Table'[Your specific month]), 1 )
Return
Calculate( [Sales] ,  'Calendar'[Date] >= selecteddate )


Then apply the black color the the measure before x and red to the measure after x. 

Let me know how it goes! 

Br,
J


Connect on LinkedIn
arjumandsheikh
Regular Visitor

thanks for your answer

 

MFelix
Super User
Super User

Hi @arjumandsheikh ,

 

For this you need to create two measure and make the lines on top of each other something similar to:

 

 

Before Month =
CALCULATE (
    SUM ( Table[Sales] ),
    FILTER ( ALLSELECTED ( Table[Date] ), Table[Date] <= MAX ( Slicer[Date] ) )
)

After Month =
CALCULATE (
    SUM ( Table[Sales] ),
    FILTER ( ALLSELECTED ( Table[Date] ), Table[Date] >= MIN( Slicer[Date] ) )
)

 

 

Be aware that this sintax may need some changes.

 

Then just place the two lines on the values of the line chart.

 

If this does not work can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.