Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

PowerBI API not found for Cardinality(Many to Many) while creating DataSets or tables

I am looking for API details to create dataset with many to many cardinality relationship between tables.

I have multiple tables and I am able to give BothDirections relationships using API but unable to find any API for cardinality.

Below is API endpoint which I am using to create datasets:

https://api.powerbi.com/v1.0/myorg/groups/{ID}/datasets

Any recommendations please.

TIA.

 

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

Are you using the following REST API to create the dataset? According to my research, there is no explicit definition of the cardinality property exactly. I think it may be because power BI intelligently identifies the cardinality between tables based on the data in the tables.

Push Datasets - Datasets PostDatasetInGroup

yingyinr_0-1668580930429.png

Please review the blog below to see if you can programmatically define the cardinality value explicitly.

Programming Datasets with the Tabular Object Model (TOM)

model.Relationships.Add(new SingleColumnRelationship {
  Name = "Products to Sales",
  ToColumn = tableProducts.Columns["ProductId"],
  ToCardinality = RelationshipEndCardinality.One,
  FromColumn = tableSales.Columns["ProductId"],
  FromCardinality = RelationshipEndCardinality.Many
});

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

Thank you for your response.

 

I tried same approach but not worked for me.

API Endpoint - https://api.powerbi.com/v1.0/myorg/groups/{ID}/datasets

Below is snippet from request:

{
"fromColumn": "judgeId",
"fromTable": "DocketJudge",
"ToCardinality": "one",
"name": "judgeEducation",
"toColumn": "judgeId",
"toTable": "JudgeEducation",
"FromCardinality": "many",
"crossFilteringBehavior": "bothDirections"
}

 

It failed with 400 Bad Request error saying "The property 'ToCardinality' does not exist on type 'Microsoft.PowerBI.ServiceContracts.Api.Relationship"

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors