Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
pbidani
Frequent Visitor

Bar Chart - conditional formatting - diff colors based on upn

Hello,

I will appreciate suggestions on formatting a bar chart --  

x axis is club abbrev, Y axis is revenue per club. 

User table (called userinfo) has user club abbrev (the club the user belongs to) and the user email.  

Need to show diff color on the bar and club abbrev for each user based on the upn.  

 

The below code works well to change the color of bars in a bar chart - using Format, Columns, Color -- fx. 

 

But it does not work to change the colors of club abbrev on the x axis - using Format, x axis, values ---  .

 

Color Bars =

VAR _upn = USERPRINCIPALNAME()

VAR _UserClub = CALCULATE(

     MAX('a-vw_sponsorship'[club_abbrev]),

    'UserInfo'[user_email] = _upn

)

RETURN

IF(

   MAX('a-vw_sponsorship'[club_abbrev]) = _UserClub,

    "#12239e",  -- Blue for the user's club

    "#b3b3b3"   -- Gray for other clubs

 )

 

I will appreciate any thoughts or suggestions.

Regards,

Pav

4 REPLIES 4
Kedar_Pande
Super User
Super User

@pbidani 

The issue here is that Power BI doesn’t support dynamic formatting of axis labels directly based on DAX logic.

Some custom visuals, like Deneb (Vega-Lite JSON-based) or third-party visuals, allow more flexible formatting, including the dynamic coloring of axis labels. Using these, you can dynamically format both bars and axis labels based on the same logic.

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Thanks Kedar. 

I looked but was not able to find the Deneb bar chart.  Any specifics on how to find it?

pbidani_0-1731938821297.png

I was trying to use the Format, X axis, Values, fx, and dax to make it work.

Thanks again!!

rajendraongole1
Super User
Super User

Hi @pbidani - Create a new measure that outputs the user's club abbreviation as a label

Highlighted Club =
VAR _upn = USERPRINCIPALNAME()
VAR _UserClub = CALCULATE(
MAX('a-vw_sponsorship'[club_abbrev]),
'UserInfo'[user_email] = _upn
)
RETURN
IF(
MAX('a-vw_sponsorship'[club_abbrev]) = _UserClub,
MAX('a-vw_sponsorship'[club_abbrev]),
BLANK()
)

 

Currently, you can highlight the user's club visually in the bars themselves and add supporting elements (like tooltips, legends, or secondary visuals) for further differentiation. If the formatting of the axis labels themselves is critical, you may need to wait for future updates to Power BI or use a custom visual.

 

Hope it works, please check





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thanks Rajendra. 

 

pbidani_0-1731938821297.png

I was trying to use the Format, X axis, Values, fx, and dax to make it work.

Thanks again!!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.