Forum Discussion

sebastien_druon's avatar
sebastien_druon
Frequent Visitor
5 years ago
Solved

Handling null in one-to-many relationship

Hello

 

I have 2 simple tables with what I would expect to be a 1 to many relationship.

 

Problem 1

PowerBI however imposes a many-to-many relationship

Here are the table contents, the "Customers" table containing a null value:

How can I avoid powerbi creating a many-to-many relationship?

 

Problem 2

I created a simple table visual to display the number of tickets per customer.

I would expect Customer A and Customer B to appear, with a count of 0 for Customer A.

PowerBI does not display Customer A at all though

How can I solve that issue?

 

Many thanks!

 

PS: a copy of the pbix file here:

https://1drv.ms/u/s!AsdHsyy8cIM4jcAt62ZodGYi0CHMqw?e=WXeP7B

  • Hi, sebastien_druon 

    #1  The cardinality type selected  in relationship depends on the data in the tables("SystemID"  contains blank value).If you force a one-to-many relationship between tables, the following error will be reported.

     

    As a workaround, you can change the type of column 'SystemID' from "whole number" to 'Text'.

     

    #2 
    You need to enable the option "show items with no data" of filed "Data"

    You can also directly create a new measure 'Count of ticket' to replace the original field"ticket" as below:

     

     

    Count of ticket = COUNT(Tickets[Ticket])+0

     

     

     

     

    Please  check my sample pbix file for more details.

     

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

3 Replies

  • v-easonf-msft's avatar
    v-easonf-msft
    Icon for Community Support rankCommunity Support

    Hi, sebastien_druon 

    #1  The cardinality type selected  in relationship depends on the data in the tables("SystemID"  contains blank value).If you force a one-to-many relationship between tables, the following error will be reported.

     

    As a workaround, you can change the type of column 'SystemID' from "whole number" to 'Text'.

     

    #2 
    You need to enable the option "show items with no data" of filed "Data"

    You can also directly create a new measure 'Count of ticket' to replace the original field"ticket" as below:

     

     

    Count of ticket = COUNT(Tickets[Ticket])+0

     

     

     

     

    Please  check my sample pbix file for more details.

     

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

  • Hi,

    Create a third table which should list down all the unique ID's (without blanks).  Now connect the ID columns of the 2 tables to this third table.  Create a Many to One relationship wth cardinality of Single. 

  • BrennoBBS's avatar
    BrennoBBS
    Regular Visitor

    Was going crazy and creating a new related table with Dax just because it wasn't showing null values.

     

    This info: "You need to enable the option "show items with no data" of filed "Data"" saved my life, thank you so much sir! 🙂