<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Adding Date Hierarchy programmatically to PBI Embed using JS in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Adding-Date-Hierarchy-programmatically-to-PBI-Embed-using-JS/m-p/3570873#M45679</link>
    <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;I'm using powerbi JS and&amp;nbsp;powerbi-report-authoring JS to create an embed, where I generate visuals, and to these visuals I want to add in a Date Hierarchy, in this case the visual type is a tableEx, and the data I want to upload is the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"prototypeQuery": {
	"Version": 2,
	"From": [{
			"Name": "p",
			"Entity": "potentialTypes",
			"Type": 0
		}
	],
	"Select": [{
			"HierarchyLevel": {
				"Expression": {
					"Hierarchy": {
						"Expression": {
							"PropertyVariationSource": {
								"Expression": {
									"SourceRef": {
										"Source": "p"
									}
								},
								"Name": "Variation",
								"Property": "Date"
							}
						},
						"Hierarchy": "Date Hierarchy"
					}
				},
				"Level": "Year"
			},
			"Name": "potentialTypes.Date.Variation.Date Hierarchy.Year",
			"NativeReferenceName": "Date Year"
}]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and here is the code I use to upload the data into the visual&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;visual.addDataField(Object.keys(item.singleVisual.projections)[0], {
    $schema: "http://powerbi.com/product/schema#hierarchyLevel",
    table: dataFields.Name.split('.')[0],
    hierarchy: dataFields.HierarchyLevel.Expression.Hierarchy,
    hierarchyLevel: dataFields.HierarchyLevel
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the following error when I run this:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{message: 'FailedToAddDataField', detailedMessage: 'Failed to add data field to role'}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried it without the hierarchy (replacing it with HierarchyLevel, Expression), I tried it with different Hierarchical data, I tried burning in the data, I went though the whole microsoft learn wiki (&lt;A href="https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/data-fields)" target="_blank"&gt;https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/data-fields)&lt;/A&gt;&amp;nbsp;but to no avail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only way that works is if I use column instead of the hierarchy, however the problem then that it creates all of the Date Time hierarchy, not just the one I specified, this also means that I am unable to add a normalized Date (that is not a Hierarchy) to a field programmatically, because it turns into a Hierarchy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am unable to add only a specific level of the Date Hierarchy to the visual programmatically; it either fails or adds the entire hierarchy, which is not the desired outcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone encountered this issue before or successfully added a specific level of a Date Hierarchy to a visual using Power BI's JavaScript API?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any insights or guidance would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Dec 2023 16:11:41 GMT</pubDate>
    <dc:creator>Dan3</dc:creator>
    <dc:date>2023-12-06T16:11:41Z</dc:date>
    <item>
      <title>Adding Date Hierarchy programmatically to PBI Embed using JS</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Adding-Date-Hierarchy-programmatically-to-PBI-Embed-using-JS/m-p/3570873#M45679</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;I'm using powerbi JS and&amp;nbsp;powerbi-report-authoring JS to create an embed, where I generate visuals, and to these visuals I want to add in a Date Hierarchy, in this case the visual type is a tableEx, and the data I want to upload is the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"prototypeQuery": {
	"Version": 2,
	"From": [{
			"Name": "p",
			"Entity": "potentialTypes",
			"Type": 0
		}
	],
	"Select": [{
			"HierarchyLevel": {
				"Expression": {
					"Hierarchy": {
						"Expression": {
							"PropertyVariationSource": {
								"Expression": {
									"SourceRef": {
										"Source": "p"
									}
								},
								"Name": "Variation",
								"Property": "Date"
							}
						},
						"Hierarchy": "Date Hierarchy"
					}
				},
				"Level": "Year"
			},
			"Name": "potentialTypes.Date.Variation.Date Hierarchy.Year",
			"NativeReferenceName": "Date Year"
}]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and here is the code I use to upload the data into the visual&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;visual.addDataField(Object.keys(item.singleVisual.projections)[0], {
    $schema: "http://powerbi.com/product/schema#hierarchyLevel",
    table: dataFields.Name.split('.')[0],
    hierarchy: dataFields.HierarchyLevel.Expression.Hierarchy,
    hierarchyLevel: dataFields.HierarchyLevel
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the following error when I run this:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{message: 'FailedToAddDataField', detailedMessage: 'Failed to add data field to role'}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried it without the hierarchy (replacing it with HierarchyLevel, Expression), I tried it with different Hierarchical data, I tried burning in the data, I went though the whole microsoft learn wiki (&lt;A href="https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/data-fields)" target="_blank"&gt;https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/data-fields)&lt;/A&gt;&amp;nbsp;but to no avail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only way that works is if I use column instead of the hierarchy, however the problem then that it creates all of the Date Time hierarchy, not just the one I specified, this also means that I am unable to add a normalized Date (that is not a Hierarchy) to a field programmatically, because it turns into a Hierarchy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am unable to add only a specific level of the Date Hierarchy to the visual programmatically; it either fails or adds the entire hierarchy, which is not the desired outcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone encountered this issue before or successfully added a specific level of a Date Hierarchy to a visual using Power BI's JavaScript API?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any insights or guidance would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2023 16:11:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Adding-Date-Hierarchy-programmatically-to-PBI-Embed-using-JS/m-p/3570873#M45679</guid>
      <dc:creator>Dan3</dc:creator>
      <dc:date>2023-12-06T16:11:41Z</dc:date>
    </item>
  </channel>
</rss>

