cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Conditional formatting on rows values

Hi,

 

I'm trying to make the table bellow in Power BI but I don't know how to make this conditional formatting...

 

Basically it compares the numbers between the years. If the result is higher than the previously it becomes green, if it is lower it becomes red

 

Capturar.PNG

 

Thanks for any help

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Responsive Resident
Responsive Resident

Re: Conditional formatting on rows values

Hi @Pedro_Lourenco , 

 

A measure like this can give you the "status" per year. The "status" can than be used to control the conditional formatting.
It assumes that you have a data table like "name", "year", "result"

R1 = 
var LastYear = if (HASONEVALUE(Results[Year]), VALUES('Results'[Year])-1)
var LastYearResult = CALCULATE( sum(Results[Result]), 'Results'[Year]=LastYear)
var CurrentYearResult = sum('Results'[Result])
return
if (LastYearResult<CurrentYearResult, 1,-1)
 
20200111-result.jpg

 

Regards, 

 

Jan 

(if this is a solution for you don't forget to mark it as a solution) 

View solution in original post

2 REPLIES 2
Highlighted
Responsive Resident
Responsive Resident

Re: Conditional formatting on rows values

Hi @Pedro_Lourenco , 

 

A measure like this can give you the "status" per year. The "status" can than be used to control the conditional formatting.
It assumes that you have a data table like "name", "year", "result"

R1 = 
var LastYear = if (HASONEVALUE(Results[Year]), VALUES('Results'[Year])-1)
var LastYearResult = CALCULATE( sum(Results[Result]), 'Results'[Year]=LastYear)
var CurrentYearResult = sum('Results'[Result])
return
if (LastYearResult<CurrentYearResult, 1,-1)
 
20200111-result.jpg

 

Regards, 

 

Jan 

(if this is a solution for you don't forget to mark it as a solution) 

View solution in original post

Highlighted
Community Support
Community Support

Re: Conditional formatting on rows values

Hi @Pedro_Lourenco ,

 

We can set condiftion formatting based on the measure as below.

Measure = 
VAR pre =
    MAX ( 'Table'[Year] ) - 1
VAR va =
    SUM ( 'Table'[value] )
VAR pres =
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER ( ALLEXCEPT ( 'Table', 'Table'[Name] ), 'Table'[Year] = pre )
    )
RETURN
    IF ( pres = BLANK (), BLANK (), IF ( pres > va, "red", "green" ) )

Capture.PNG

 

Pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Upcoming Events

Community Summit North America – Join Online!

Join this community-driven Power Platform digital event for unbiased support and problem-solving.

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Top Solution Authors