Forum Discussion

luisJarmanCP's avatar
luisJarmanCP
New Member
3 years ago

Unable to Add 'Year' HierarchyLevel to DataField with Power BI JS Client

Hello Community,

I'm currently developing a project with the Power BI JavaScript Client and I've encountered an issue that I could use some assistance with.

To provide some context, I am working with a dataset that includes several tables. Among these tables, there's one titled "Product Daily Prices". This table has a column named "Price Date" which contains a "Date Hierarchy". This hierarchy includes levels for Year, Quarter, Month, and Day.

 

I have been attempting to utilize the Report Authoring SDK to append the "Year" hierarchy level with the following code:

 

await visual.addDataField('Category', {
table: 'Product Daily Prices',
hierarchy: 'Price Date',
hierarchyLevel: 'Year',
$schema: "http://powerbi.com/product/schema#hierarchyLevel",
});

 

I also tried to adjust the hierarchy parameter in my code to 'Date Hierarchy', to see if this was the cause of the issue:

await visual.addDataField('Category', {
table: 'Product Daily Prices',
hierarchy: 'Date Hierarchy',
hierarchyLevel: 'Year',
$schema: "http://powerbi.com/product/schema#hierarchyLevel",
});

However, both of these code snippets result in the same error:

{
"message": "FailedToAddDataField",
"detailedMessage": "Failed to add data field to role"
}

 

I have been unable to find the cause of this problem and would appreciate any guidance on resolving this. Has anyone else experienced this issue when attempting to add a hierarchy level to a data field with the Power BI JS Client?

Thanks in advance for your help.

Best regards,
Luis

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Have encounter the same problem too, have you found the solution yet?