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

Color specific cells

Hello!

 

I want to color everything that is before Q1 2024 in green (instead of blue): 

 

naimazhusupova_0-1706089823010.png

 

I tried to use the following measure:

 

CF Gantt =
VAR StartDate =
CALCULATE(
    MIN('reset programs'[Start date]),
    REMOVEFILTERS(dimDate))
VAR EndDate =
CALCULATE(
    MIN('reset programs'[End date]),
    REMOVEFILTERS(dimDate))
VAR ProjectPeriod =
    MIN(dimDate[Date]) >= StartDate
    && MIN(dimDate[Date]) <= EndDate
VAR Status1 =
    MIN('reset programs'[State]) = "Completed"
VAR Country =
    MIN('reset programs'[Country])
VAR Result =
IF (
    Status1,
    2,
    IF (
        ProjectPeriod,
        1
    )
)

RETURN
    Result
 
 
So it colors green whenever the 'State' is Completed, but it doesn't color the whole line. So could anyone help me?
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

 

I understand your problem:

What you need is to set all values before a certain date to green, then set the color of values that have a status of ‘Complete’(The return value is 2) after the date to green, and the others to blue.

I create a set of sample date:

vzhengdxumsft_0-1706161677377.png

Then create a measure:

color = IF(
            MONTH(MAX('Table'[date]))<3
            &&
            YEAR(MAX('Table'[date]))=2023,
                "green",
//Highlight data prior to March 2023 in green
                IF(
                    MAX('Table'[status])=2,
                        "green",
                        "blue" 
              )
//Data with a status of 2 after March is marked in green, and others are in blue
        )


Create a matrix and right-click the values and click the Conditional formatting > Background color

vzhengdxumsft_1-1706161677379.png

Field style > (What field should we base this on?)color

 

vzhengdxumsft_2-1706161694263.png

The result is as follow:

vzhengdxumsft_3-1706161694265.png

 

Best Regards,

Zhengdong Xu

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

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous 

 

I understand your problem:

What you need is to set all values before a certain date to green, then set the color of values that have a status of ‘Complete’(The return value is 2) after the date to green, and the others to blue.

I create a set of sample date:

vzhengdxumsft_0-1706161677377.png

Then create a measure:

color = IF(
            MONTH(MAX('Table'[date]))<3
            &&
            YEAR(MAX('Table'[date]))=2023,
                "green",
//Highlight data prior to March 2023 in green
                IF(
                    MAX('Table'[status])=2,
                        "green",
                        "blue" 
              )
//Data with a status of 2 after March is marked in green, and others are in blue
        )


Create a matrix and right-click the values and click the Conditional formatting > Background color

vzhengdxumsft_1-1706161677379.png

Field style > (What field should we base this on?)color

 

vzhengdxumsft_2-1706161694263.png

The result is as follow:

vzhengdxumsft_3-1706161694265.png

 

Best Regards,

Zhengdong Xu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.