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
tomdenby
Frequent Visitor

map data role to Variable in visual.ts

Hi  ,

 

Im trying to map a data role to a variable in Visual.ts.

 

I know how to create the data role but for some reason cant get it to map to a variable.

 

does anyone know of any simple tutorials or youtube videos that go through and explain the steps?

 

Thanks, 

 

Tom. 

5 REPLIES 5
paul-maessen
Resolver I
Resolver I

@tomdenby 

 

I am not sure what you want to capture in the variable, but when you want to know what data is added to a certain dataRole in your visuals you can look into the DataView.

 

You can find the metadata-property there that contains all data-columns added to your visuals (dataView[0].metadata.columns). Each MetaDataColumn has a roles-proprty that contains a property with the name of the dataRole it has been added to.

 

You also could use the DataViewUtils provided by Microsoft to get this information out of the DataView.

 

I hope this will help you further developping your own visuals.

 

Regards

 

Paul

@paul-maessen 

thanks for your comment. i will look into this  more shortly. 

 

just to add some more context what i would like to do is map the data value to a configuaration variable within the code as part of an API call to get authentication, it will always be a single value. rather than a table or values to display within the visual.  hope this helps 

@tomdenby 

 

The problem with the custom visuals is that you only get one dataView returned. You can specify multiple dataViews but depending on the conditions you have set the API only returns one dataView.

 

So if you only need one single value then it sould be part of the dataView you are using which can be a single Value but mostly is categorical, table or matrix. 

 

So if you only provide a single Value for authentication you dont have other data for your visual 🙂

In this case it might be logical that your authentication value is part of your dataView and probably repeated in your table or values.

 

Regards

 

Paul

 

v-yiruan-msft
Community Support
Community Support

Hi @tomdenby ,

Please review the content in the following link, hope it can help you.

Build Your Custom Visuals in Power BI

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

thanks for your comment i will look into this further over the next week 

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.