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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Change Line color based on previous quarter

Hi, I have calculated column:

Quarter = QUARTER('tableXXX'[Date])
then I want to create two lines: one(red) if the current quarter is less than previus and second line (green) if current quarter is more than previus. 
 
I create two measure current quarter:
cq = CALCULATE(Sum('tableXXX'[CurrentNumber]) / Sum('tableXXX'[Total Possible Number]),
     'tableXXX'[Type]="SpecificType", 'tableXXX'[Quarter]=QUARTER(TODAY()))
 
and previus quarter:
cq = CALCULATE(Sum('tableXXX'[CurrentNumber]) / Sum('tableXXX'[Total Possible Number]),
     'tableXXX'[Type]="SpecificType", 'tableXXX'[Quarter]=QUARTER(TODAY()) -1)
 
My lines are : 
DownLine = if( [cq] <[pq] , [Measure%], BLANK() )
UpLine = if( [cq] >[pq] , [Measure%], BLANK() )
 
 
Measure% = CALCULATE(
     ( Sum('tableXXX'[CurrentNumber]) / Sum('tableXXX'[Total Possible Number])),
     'tableXXX'[ype]="SpecificType")
 
 
Problem: if I use two measures in if statement for example pq and cq  later the line chart dont show line, its only show one quarter. If I use at least one number for example pq>5 then line chart show correctly all quarters on the chart.
 
I suspect that is something with context but I dont know how to resolve this pre
 
 
2 REPLIES 2
Anonymous
Not applicable

I followed thanks

PaulDBrown
Community Champion
Community Champion

Please follow the recommendations in this thread to help us help you:

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.