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
mosam
Frequent Visitor

Conditional Formatting using Dax

Site Name7/9/20237/10/20237/11/2023
Ahangama110010581070
Akmeemana106310161094

 

I have above table with some more data. If current dates count is higher than the previous dates count I want to highlight current date count red. If current dates count is less than the previuos dates count  I want to highlight current date count red. How to achieve this using power bi?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @mosam ,

 

"Current dates count is higher than the previous dates count" means the largest count.

 

1.Here suppose your count is a column.

Raw sample data:

vstephenmsft_2-1692950595241.png

So you can create a measure like:

 

Measure = var _max=MAXX(FILTER(ALLSELECTED('Table'),[Site Name]=MAX('Table'[Site Name])),[Count])
return IF(_max=SUM('Table'[Count]),"Red")

 

Conditional Formatting in the matrix:

vstephenmsft_0-1692950526633.png

Result:

vstephenmsft_1-1692950535918.png

2.If you count is a measure.

Raw sample data:

vstephenmsft_4-1692950781172.png

vstephenmsft_3-1692950766982.png

Create a measure for conditional formatting:

Measure 3 = var _max=MAXX(FILTER(ALLSELECTED('Table (2)'),[Site Name]=MAX('Table (2)'[Site Name])),[Measure 2])
return IF(_max=[Measure 2],"red")

After conditional formatting is set, the result is below.

vstephenmsft_5-1692950913692.png

Hope that helps.

 

                                                                                                                              

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi @mosam ,

 

"Current dates count is higher than the previous dates count" means the largest count.

 

1.Here suppose your count is a column.

Raw sample data:

vstephenmsft_2-1692950595241.png

So you can create a measure like:

 

Measure = var _max=MAXX(FILTER(ALLSELECTED('Table'),[Site Name]=MAX('Table'[Site Name])),[Count])
return IF(_max=SUM('Table'[Count]),"Red")

 

Conditional Formatting in the matrix:

vstephenmsft_0-1692950526633.png

Result:

vstephenmsft_1-1692950535918.png

2.If you count is a measure.

Raw sample data:

vstephenmsft_4-1692950781172.png

vstephenmsft_3-1692950766982.png

Create a measure for conditional formatting:

Measure 3 = var _max=MAXX(FILTER(ALLSELECTED('Table (2)'),[Site Name]=MAX('Table (2)'[Site Name])),[Measure 2])
return IF(_max=[Measure 2],"red")

After conditional formatting is set, the result is below.

vstephenmsft_5-1692950913692.png

Hope that helps.

 

                                                                                                                              

Best Regards,

Stephen Tao

 

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

 

piotr_gor
Helper II
Helper II

Hi, 

It depends of rest of date values, but for given dataset this might work. 

Then you apply Conditional Formatting to [Count] and in "Format style" you select newly created measure [Formatting].

Formatting = 
VAR _Current_Date = MAX( 'Table'[Date] ) 
VAR _Current_Count = [Count]

VAR _Before = DATEADD( 'Table'[Date], -1, MONTH )
VAR _Before_Count = 
    CALCULATE( 
        [Count],
        _Before
    )

VAR _Result = 
    IF( 
        AND( _Current_Count > 0, _Before_Count > 0 ),
        IF(
            _Current_Count > _Before_Count, 
            "#BC544B"
        )
    )


RETURN 
    _Result

 

mosam_0-1692339913427.png

This is the complete table.

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.