Forum Discussion
Conditional formatting matrix: Comparing cells to adjacent value
- 7 years ago
hi, Sweet-T
I continue to work on this requirement, and today I find a way may achieve your requirement.
Sorry about my carelessness.
Now, this is a new way for you refer to;
basic data
Step1:
Add a Year Quarter Number column
Year Quarter Number = YEAR ( Table1[Date] ) * 100 + INT ( FORMAT ( [Date], "q") )
Step2:
Add this measure
%change = VAR previousDate = CALCULATE ( MAX ( Table1[Date] ), FILTER ( ALLSELECTED ( Table1 ), Table1[Qty] > 0 && Table1[Date] < MAX ( Table1[Date] ) ) ) VAR previousYQ = CALCULATE ( MAX ( Table1[Year Quarter Number] ), FILTER ( ALLSELECTED ( Table1 ), Table1[Qty] > 0 && Table1[Year Quarter Number] < MAX ( Table1[Year Quarter Number] ) ) ) VAR previousREG = CALCULATE ( SUM ( Table1[Qty] ), FILTER ( ALLSELECTED ( Table1 ), Table1[Date] = previousDate ) ) VAR previousYQTOTAL = CALCULATE ( SUM ( Table1[Qty] ), FILTER ( ALLSELECTED ( Table1 ), Table1[Year Quarter Number] = previousYQ ) ) VAR previousQty = IF ( ISFILTERED ( Table1[Date].[Quarter] ), previousYQTOTAL, IF ( ISFILTERED ( Table1[Date].[Month] ), previousREG ) ) RETURN DIVIDE ( SUM ( Table1[Qty] ) - previousQty, previousQty, 0 )Step3:
Add Conditional formatting for matrix
Result:
here is pbix, please try it.
https://www.dropbox.com/s/j3sraf440cbjs13/Conditional%20formatting%20for%20matrix.pbix?dl=0
Best Regards,
Lin
hi, Sweet-T
I continue to work on this requirement, and today I find a way may achieve your requirement.
Sorry about my carelessness.
Now, this is a new way for you refer to;
basic data
Step1:
Add a Year Quarter Number column
Year Quarter Number = YEAR ( Table1[Date] ) * 100 + INT ( FORMAT ( [Date], "q") )
Step2:
Add this measure
%change =
VAR previousDate =
CALCULATE (
MAX ( Table1[Date] ),
FILTER (
ALLSELECTED ( Table1 ),
Table1[Qty] > 0
&& Table1[Date] < MAX ( Table1[Date] )
)
)
VAR previousYQ =
CALCULATE (
MAX ( Table1[Year Quarter Number] ),
FILTER (
ALLSELECTED ( Table1 ),
Table1[Qty] > 0
&& Table1[Year Quarter Number] < MAX ( Table1[Year Quarter Number] )
)
)
VAR previousREG =
CALCULATE (
SUM ( Table1[Qty] ),
FILTER ( ALLSELECTED ( Table1 ), Table1[Date] = previousDate )
)
VAR previousYQTOTAL =
CALCULATE (
SUM ( Table1[Qty] ),
FILTER ( ALLSELECTED ( Table1 ), Table1[Year Quarter Number] = previousYQ )
)
VAR previousQty =
IF (
ISFILTERED ( Table1[Date].[Quarter] ),
previousYQTOTAL,
IF ( ISFILTERED ( Table1[Date].[Month] ), previousREG )
)
RETURN
DIVIDE ( SUM ( Table1[Qty] ) - previousQty, previousQty, 0 )Step3:
Add Conditional formatting for matrix
Result:
here is pbix, please try it.
https://www.dropbox.com/s/j3sraf440cbjs13/Conditional%20formatting%20for%20matrix.pbix?dl=0
Best Regards,
Lin
Lin, THANK YOU!
This is really cool, I apprecaite you taking the time to figure this out. This is a great base; I simplified my model for the sake of explaining my need. I will take what you have given me and try it this weekend, then report back.
Thanks again,
T