Forum Discussion

power_bi_123456's avatar
power_bi_123456
Frequent Visitor
2 years ago

Conditional Formatting Cell based on Attribute/Dimension

I've created a table matrix which contains media data. The rows contain Brand Name, Campaign Name, Start Date, End Date and Net Spend. The columns have Year, Quarter and Month. For the values, I created a measure which breaks out spend by day so that I can visualize how much is spent over time. I included the calculation below although I don't think it's neccesary for my use case.

 

I need to have each cell color coded by brand. However, for conditional formatting there doesn't seem to be an easy way to do this whether it's based on field value or rules. Please help?

 

Spend Calculation: 

Measure =
IF(
    CALCULATE(
        SUMX(
            SUMMARIZE(
                FILTER(
                    CROSSJOIN(Summary, 'DateTable'), 
                    'DateTable'[Date] >= Summary[Start_Date] && 'DateTable'[Date] <= Summary[End_Date]
                ),
                Summary[Net Spend],
                'DateTable'[Date],
                "_sum",
                SUM(Summary[Daily Spend Value])
            ),
            [_sum]
        )
    ) = 0,
    BLANK(),
    CALCULATE(
        SUMX(
            SUMMARIZE(
                FILTER(
                    CROSSJOIN(Summary, 'DateTable'),
                    'DateTable'[Date] >= Summary[Start_Date] && 'DateTable'[Date] <= Summary[End_Date]
                ),
                Summary[Net Spend],
                'DateTable'[Date],
                "_sum",
                SUM(Summary[Daily Spend Value])
            ),
            [_sum]
        )
    )
)