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
Anonymous
Not applicable

extracting metadata from dataview

module powerbi.visuals {

    export class MyHelloWorld implements IVisual {
        public static capabilities: VisualCapabilities = { };
        
        private hostContainer: JQuery;
        private table: JQuery;

        public init(options: VisualInitOptions): void {
            this.hostContainer = options.element;
			
			this.hostContainer.append(
				"<table id='MyTableVisual'>" +
                  "<thead><tr>" +
                     "<th>Column</th>" +
                     "<th>isMeasure</th>" +
                     "<th>QueryName</th>" +
                     "<th>GroupName</th>" +
                     "</tr></thead>" +
                  "<tbody></tbody>" +
                "</table>"
			);
        }
        
        public update(options: VisualUpdateOptions) {
            var dataViews = options.dataViews;
            if (!dataViews) return;
            
            $("#MyTableVisual tbody").empty();
            
            var columns = dataViews[0].metadata.columns;
            for (var i = 0; i < columns.length; i++)
            {
                var newHtml = [];
                newHtml.push("<tr>")                
                newHtml.push("<td>" + columns[i].displayName + "</td>")
                newHtml.push("<td>" + columns[i].isMeasure + "</td>") 
                newHtml.push("<td>" + columns[i].queryName + "</td>")
                newHtml.push("<td>" + columns[i].groupName + "</td>")
                newHtml.push("</tr>")
                
                $("#MyTableVisual").append(newHtml.join())
            }           
        }		
    }
}

I am trying to play with visuals, and I am 1 step behind "Hello, World!".  I thought I would output the metadata... but the results are totally not what I expect.   eg: if I use the "FileStorage" dataset, I get...

 

Column isMeasure QueryName GroupName

DateundefinedDateundefined
SalestruebmwBMW
SalestruealfaAlfa Romeo

 

which doens't seem to map that well to : 

https://github.com/Microsoft/PowerBI-visuals/blob/master/src/Clients/PowerBIVisualsPlayground/sample...

 

am I missing something here?  or does my code just suck? 🙂

0 REPLIES 0

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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