Pietro
Pietro

Reputation: 19

How to detect if a field is formatted as currency in Power BI custom visual when format property is not available?

I'm developing a custom Power BI visual using TypeScript and the Power BI Visuals API. In my visual, I need to determine if a data field is formatted as currency (or any other format options) in the Power BI Desktop model so that I can apply appropriate formatting in my visual.

However, I'm encountering an issue where the format property is not available in the DataView's metadata columns.

I've tried inspecting the dataView's table property and checking if the columns have the format element inside, but without success.

const tableDataView: DataViewTable = dataView.table;

for(let c = 0; c < tableDataView.columns.length; c++)
{
    console.log(c);
    console.log(tableDataView.columns[c]);
...
}

Also checking the metadata object is not helping.

In the end, I want to apply the same currency formatting in my custom visual that is set in Power BI Desktop for consistency. Any guidance on how to achieve this would be greatly appreciated.

Upvotes: 0

Views: 16

Answers (0)

Related Questions