Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I want to highlight current month (may) in below stacked column chart and I am not able to find conditional formatting for stacked colomn chart. Any idea on how to highlight current month. Below chart has 4 legends.
A bit hacky, but you could just make a measure that only displays in the current month, then put that measure on a combo chart with your actual series.
The measure you'd need looks like this:
CurrentMonth = IF( HASONEVALUE( 'Date'[YearMonth] ) ,IF( VALUES( 'Date'[YearMonth] ) = LOOKUPVALUE( 'Date'[YearMonth] ,'Date'[Date] ,TODAY() ) ,<expression for height> ) )
You could just put 1 as your height expression and use two y axes, but you'll end up with an extra axis on one side ranging from 0 to 1. If you want to plot them on the same y axis, then you'd need to define something that's larger than the values in your line series. I used something like the following:
CurrentMonth = IF( HASONEVALUE( 'Date'[YearMonth] ) ,IF( VALUES( 'Date'[YearMonth] ) = LOOKUPVALUE( 'Date'[YearMonth] ,'Date'[Date] ,TODAY() ) ,MAXX( ALL( 'Date'[YearMonth] ) ,CALCULATE( SUM( FakeData[Value] ) ) ) * 1.25 ) )
The only difference is the MAXX() in there. It finds the largest monthly value of FakeData[Value] and then multiplies it by 1.25 This guarantees it's larger than my line series (which is just SUM( FakeData[Value] )), but still proportional, allowing it to fit well on the same y axis.
The measure is fairly simple. First we check if there's exactly one value for [YearMonth] in context (necessary for the next IF() function).
Then we evaluate VALUES( 'Date'[YearMonth] ) - this gives us all distinct values of that field in context, if there's only 1, then it is cast as a scalar value implicitly, allowing us to compare with the result of LOOKUPVALUE() for equality.
LOOKUPVALUE() just returns the value of [YearMonth] where [Date] = TODAY(). If the [YearMonth] in context is the same as today's, we return the MAXX() or whatever other expression you used there. If not, we return blank. If there's more than one [YearMonth] in context (like in a subtotal of any sort), the measure returns blank.
Here's a sample PBI report where I've implemented this:
Thank you for posting, I just used this and was able to highlight the current month (February) 🙂
Here is a Hack to highlight the same.
Solved: Highlight current month in yearly view - Microsoft Power BI Community
Regards,
Ritesh
Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !!Power BI for Tableau Users
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
101 | |
79 | |
72 | |
64 |
User | Count |
---|---|
142 | |
108 | |
101 | |
81 | |
74 |