Forum Discussion
Conditional formatting based on differences between months in a matrix.
- Anonymous6 years ago
Hello sbm
This measure should do exactly what you are looking for:
Coloring = VAR FXvalue = [Total Sales] VAR FXLastMonth = CALCULATE ( SUM ( FactTable[LineTotal] ); PREVIOUSMONTH ( MasterCalendar[Date] ) ) RETURN SWITCH ( TRUE (); FXvalue < FXLastMonth; "#ff0000"; "#90ee90" )The measure evaluates the value with the value last month and if current month is lower make it red else make it green.
Kind regards
Joren Venema
Data & Analytics Consultant
If this reply solved your question be sure to mark this post as the solution to help others find the answer more easily. - 6 years ago
You will need a Previous Month measure and % Growth measure. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Assuming you have a measure called MyMeasure that is displaying your value in your matrix you would do something like:
PreviousMonth = CALCULATE([MyMeasure],PREVIOUSMONTH(Calendar[Date])) % Growth = ([MyMeasure] - [PreviousMonth) / [PreviousMonthAlso, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008You would then base your conditional logic on % Growth.
- 6 years ago
Hi sbm ,
You can create the following measure:
Measure =
var A = CALCULATE(SUM('table'[Sales]))
var B = CALCULATE(SUM('table'[Sales]),DATEADD('Calendar'[Date],-1,MONTH))
return
IF(A < B, "#ff0000","#90ee90")
Then in Matrix Format, choose conditional format:
, enable Background color and select ‘Advanced controls’:
,choose Format by Field value and select previous measure under Based on filed
Here is the demo , please try it:
Best Regards,
Yingjie Li
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
You will need a Previous Month measure and % Growth measure. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Assuming you have a measure called MyMeasure that is displaying your value in your matrix you would do something like:
PreviousMonth = CALCULATE([MyMeasure],PREVIOUSMONTH(Calendar[Date]))
% Growth = ([MyMeasure] - [PreviousMonth) / [PreviousMonth
Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008
You would then base your conditional logic on % Growth.