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

Join us at the 2025 Microsoft Fabric Community Conference. March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for $400 discount. Register now

mike_honey

PBIP fx hack: dynamic expressions for properties - everywhere!

Summary:

 

Back in April 2019, the Conditional Formatting feature was introduced for Power BI, allowing the author to select a field or measure to set a dynamic property value, e.g. for Title text.  This is achieved through fx buttons.  Since that time, this feature has been slowly extended to cover many properties. But not all ...

 

Editing the json content in PBIP files seems to allow the setting of dynamic expressions in place of static property values - even if the Power BI UI does not provide an fx button. It seems any property can be set dynamically!

Demo Report

 

PBIP-hack-Jacek - Power BI - 00 Title A.pngPBIP-hack-Jacek - Power BI - 00 Title C.png

 

PBIP file formats:

 

The PBIP file format is in preview, and as of March 2025 there are two formats - with and without the PBIR option.  You control the format using the Power BI Desktop Options / Preview features settings.  The PBIP format is described on this documentation page.

 

Right now, I prefer the PBIP format without the PBIR option, as shown. My reason is that the PBIR option is not backwards-compatible - you cannot save from PBIR format back to PBIP or PBX format without the PBIR limitations.  As well as the PBIR limitations, many important external tools only work on PBIX or PBIP (non-PBIR) formats.

 

PBIP-hack-Jacek - Power BI - 04 PBIP options.png

 

So my first examples in the Details section below show PBIP (non-PBIR) format.  Then below that, I show the PBIR format.  PBIR format is much cleaner json - much easier to read and much easier to copy and paste nodes.  Hopefully the PBIR format is released to General Availability soon.

 

Detailed steps:

The example shown sets the Y Axis / Title text property using a measure.  There is no fx button provided for that property, so the Power BI UI only allows for entering static text values.

First, set another property using the fx button to the desired measure. Here, I set the Chart's Title / Title text to a Measure.

 

PBIP-hack-Jacek - Power BI - 01 fx popup.png

 

PBIP-hack-Jacek - Power BI - 02 fx set.png

 

Then, set the target property that you want to set dynamically. I used an easy-to-find value eg ZZZ

 

PBIP-hack-Jacek - Power BI - 02 Y Axis Title ZZZ.png

 

 

Next, open the PBIP files using VS Code or a similar editor, and find the dynamic expression that was set above. Select and copy the expr "node" in the json code. 

 

PBIP-hack-Jacek-PBIP-no-PBIR - VS Code - 01 Find and copy fx measure example.png 

Then find the target property ZZZ, and select the expr node.

 

PBIP-hack-Jacek-PBIP-no-PBIR - VS Code - 02 Find and select target literal.png

 

Paste your copied json code and save the file.  Open in Power BI Desktop and test.

 

PBIR format examples:

 

Select and copy the expr "node" in the json code. 

 

PBIP-hack-Jacek - VS Code - 01 Find and copy fx measure example.png

 

Then find the target property ZZZ, and select the expr node.

 

PBIP-hack-Jacek - VS Code - 02 Find and select target literal.png

Paste your copied json code and save the file.  Open in Power BI Desktop and test.

 

Considerations:

 

As of March 2025, the PBIP format is in preview, so the file formats might change in the future. Editing the PBIP json files is explicitly not supported.  So take care, always take a backup before any edits and test thoroughly afterwards.

I have only tested this for a handful of scenarios.  It appears to work all the way through to deployment to the web service (app.powerbi.com), which is the most common deployment scenario.


Origins and credits:

The biggest lightbulb moment for me at the Power BI and Fabric Summit 2025 conference was Jacek Nosal's session on Azure Maps. There, Jacek showed a clever hack of the PBIP format that allowed him to apply a measure to a visual property that does not support that through the Power BI UI - no fx button (in the recording from 31:20). He mentioned copying the expression code in the visual.json file, but didn't dwell on it.

At the time I just went "huh, that's weird". Then I was out walking my dog and it suddenly dawned on me that this could potentially be used anywhere ... OMG!


So I put together a demo of using it on the Column Chart's Y Axis Title, which someone mentioned cannot be set dynamically using the UI.

What do you think? IMO this has the potential to unleash a wave of PBIP hacking ("Jacek-ing"?). I am giving Jacek credit for inspiring this. I did a bit of a search and no-one else seems to have "prior art".

Comments

What an epic hack! Let's hope the #ProductTeam sees this, and makes it an official feature in the #PBIR spec!

Wow - what a great find! Thanks a lot for sharing 😁 👏

@JamesDBartlett3 thanks! Yes documenting in the spec would be a good step to make this an "official" technique.

@ImkeF thanks! I should've known this would appeal to you 😄

Hey @mike_honey, I used this technique to make something interesting: A rectangle shape on the report canvas with animated corner radius!

dynamic_corner_radius.gif

@JamesDBartlett3 I'm glad it was useful! 
I'm struggling a bit with the use case, but at the least, it further demonstrates the breadth of the opportunity space.

@mike_honey: Oh, I can't think of a use case for a rectangle with an animated corner radius property either. I just put a shape on the report canvas, picked a non-dynamic property at random, made it dynamic with the trick you demonstrated, and put a play axis slicer on it to see what would happen. I'm not aware of any prior examples of animated shapes in Power BI, and even though this specific demo probably won't win any awards, the important part is the proof of concept. It's now possible to change the shape of objects on the report canvas dynamically, based on data from the semantic model. If someone had asked me 2 weeks ago whether this was possible, I'd have laughed in their face. But now, it's a whole different ballgame.