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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
jonespossibly
Advocate I
Advocate I

is a custom visual input measure a percentage format?

Hi - i have been trying to find a way of discovering if a selected measure passed into a custom visual is of a percentage format or not.

Does anyone know where in the VisualUpdateOptions object that would be?  It doesn't seem to come through on the 

  1. categorical:
    1. values: Array(1)
      1. 0:
        1. source:

object.

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @jonespossibly,

With percentage, there is no explicit type for it. They are just regarded as numeric, so the only way to be able to determine would be through the format string, either:

  1. Under metadata.columns and the associated entry), e.g.:
    dmp_3-1633550681528.png
  2. For categorical, as per your OP, e.g.:
    dmp_4-1633550719711.png

For all data view mappings, each array element should have a source property that will contain a format string if it has been set in the data model. If this is not present then it will not have been explicitly set. If a column or measure has been set as a percentage type, then it should indeed show an appropriate format string to that effect.

If there's no format property present, you can only use the source.type property to try and derive the data type, but IIRC percentage is only stored as a numeric here, as there is no explicity type to denote, e.g.:

date.png

Note that date columns can potentially contain percentage characters in their format string, e.g.:

date.png

There could be other cases to consider, but combining a type.numeric === true along with checking the format string might be okay.

Hopefully gives you some ideas. Good luck!

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)




View solution in original post

1 REPLY 1
dm-p
Super User
Super User

Hi @jonespossibly,

With percentage, there is no explicit type for it. They are just regarded as numeric, so the only way to be able to determine would be through the format string, either:

  1. Under metadata.columns and the associated entry), e.g.:
    dmp_3-1633550681528.png
  2. For categorical, as per your OP, e.g.:
    dmp_4-1633550719711.png

For all data view mappings, each array element should have a source property that will contain a format string if it has been set in the data model. If this is not present then it will not have been explicitly set. If a column or measure has been set as a percentage type, then it should indeed show an appropriate format string to that effect.

If there's no format property present, you can only use the source.type property to try and derive the data type, but IIRC percentage is only stored as a numeric here, as there is no explicity type to denote, e.g.:

date.png

Note that date columns can potentially contain percentage characters in their format string, e.g.:

date.png

There could be other cases to consider, but combining a type.numeric === true along with checking the format string might be okay.

Hopefully gives you some ideas. Good luck!

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)




Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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