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

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.

Reply
jprmsn
Frequent Visitor

Use expression for a property value in custom visual?

Is there any way for me to allow an expression to be used for a property value?

ideally, this would be a singl text property that the user could set using a Dax expression, but I'm open to workarounds as well. Anything that could get the value of a Dax expression to my custom visual as a property as opposed to a data value. 
Thanks. 
John

5 REPLIES 5
jprdynamicapps
Helper IV
Helper IV

Thanks, Daniel. 

I can confirm that all anyone needs to do to support a formula for a color, text, icon, or web URL property is to
- update to API at least 3.5
- add an the import of VisualEnumerationInstanceKinds
- add "propertyInstanceKind: {yourPropertyName: VisualEnumerationInstanceKinds.ConstantOrRule}" to enumerateObjectInstances.

Huge thanks also for the pending reincarnation of the HTML visual!

John

jprdynamicapps
Helper IV
Helper IV

Unfortunately, apparently not supported for table and matrix dataviews.

For table and matrix mappings, it will work if you just want to populate a single property, which is how I've interpreted your original question - essentially like the way the Title text property works in the standard Title menu.

Although yes, it likely won't work if you want to do data bound mapping (e.g. rows to colors).

I've implemented this approach in the HTML Content visual, which uses a table mapping. It works perfectly fine for the "No Data" Message property:

dm-p_0-1623711113214.png

Here's a link to the location in the code where it's implemented so that you can hopefully take this and use it, if it suits your use case.

There's also a second property in the source code beneath the linked one, and this should turn up in all reports shortly, once the visual has been fully approved through to AppSource, but both work fine.





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

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




dm-p
Super User
Super User

Hi @jprmsn,

If I understand correctly, you're looking to supply the results of a measure into the propertied pane, rather than a user manually specifying a value? If so, then enabling conditional formatting for a property supports measures that return text.

Regards,

Daniel





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

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Thanks, Daniel.  Will get up to speed on that and try it out and then post back.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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