Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi,
I don't know if this is possible, if so, how to do it? If last year's value is greater than next year's, I would like to change the next year's color to red. Just like in the attached screenshot. Please help. Thank you in advance!
my date
what I want to get
Solved! Go to Solution.
@lukinfo Try this measure:
Hello,
You can achieve this using the following DAX measure
CF_FontValue =
VAR _CurrentYearResult = SUM(MyTable[Value])
VAR _PrevPer = SELECTEDVALUE(Dates[CurrYearOffset]) -1
VAR _PreviousYearResult =
CALCULATE(
SUM(MyTable[Value]),
FILTER(ALL(Dates),
Dates[CurrYearOffset] = _PrevPer)
)
VAR _Result = IF(_CurrentYearResult < _PreviousYearResult, "red", "black")
RETURN
_Result
On your matrix visual, right click on values measures and select Conditional Formatting / Font Color. Format style should be Field value based on the CF_FontValue measure. Apply on values and totals
If it answers your need, please mark my reply as the solution. Thanks!
P.S If you are looking for the Dates calendar talble I used, you can find it here:
Extended Date Table (Power Query M function) - Power Query / M Code Showcase - Enterprise DNA Forum
Thanks solutions from @Alex87 and @ChiragGarg2512 , your solutions is great.
Hi, @lukinfo
Based on the PBIX file you provided, I created a measure using the following DAX expression:
MEASURE =
VAR _curYear =
SELECTEDVALUE ( Tabela[Date].[Rok] )
VAR _curValue =
CALCULATE ( SUM ( Tabela[Value] ) )
VAR _lastyear =
CALCULATE (
SUM ( Tabela[Value] ),
FILTER (
ALLEXCEPT ( 'Tabela', 'Tabela'[Region] ),
YEAR ( 'Tabela'[Date] ) = _curYear - 1
)
)
RETURN
IF ( _lastyear > _curValue, "red" )
Using this metric in cell elements, the result is as follows:
I uploaded the PBIX file that I used this time.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
you are not following the solution steps proposed. You do not have a date table in your model. Add the date table as I recommend in my solution, adapt the formula accordingly and get rid of the Date hieararchy, and it will work.
Hello,
You can achieve this using the following DAX measure
CF_FontValue =
VAR _CurrentYearResult = SUM(MyTable[Value])
VAR _PrevPer = SELECTEDVALUE(Dates[CurrYearOffset]) -1
VAR _PreviousYearResult =
CALCULATE(
SUM(MyTable[Value]),
FILTER(ALL(Dates),
Dates[CurrYearOffset] = _PrevPer)
)
VAR _Result = IF(_CurrentYearResult < _PreviousYearResult, "red", "black")
RETURN
_Result
On your matrix visual, right click on values measures and select Conditional Formatting / Font Color. Format style should be Field value based on the CF_FontValue measure. Apply on values and totals
If it answers your need, please mark my reply as the solution. Thanks!
P.S If you are looking for the Dates calendar talble I used, you can find it here:
Extended Date Table (Power Query M function) - Power Query / M Code Showcase - Enterprise DNA Forum
@lukinfo Try this measure:
Thanks solutions from @Alex87 and @ChiragGarg2512 , your solutions is great.
Hi, @lukinfo
Based on the PBIX file you provided, I created a measure using the following DAX expression:
MEASURE =
VAR _curYear =
SELECTEDVALUE ( Tabela[Date].[Rok] )
VAR _curValue =
CALCULATE ( SUM ( Tabela[Value] ) )
VAR _lastyear =
CALCULATE (
SUM ( Tabela[Value] ),
FILTER (
ALLEXCEPT ( 'Tabela', 'Tabela'[Region] ),
YEAR ( 'Tabela'[Date] ) = _curYear - 1
)
)
RETURN
IF ( _lastyear > _curValue, "red" )
Using this metric in cell elements, the result is as follows:
I uploaded the PBIX file that I used this time.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
82 | |
76 | |
71 | |
69 | |
54 |
User | Count |
---|---|
105 | |
100 | |
91 | |
79 | |
68 |