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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Analitika
Post Prodigy
Post Prodigy

Data model

Hi,

 

I have data model but my relationships not working well. I can't callculate customers count per item, baskets. My model looks like this:

Analitika_0-1695200250321.png

Maybe I created wrong model, so how make it correct that I could use customers within items and baskets?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Analitika ,

 

You can try the following dax:

Baskets_count =
var _column=SELECTCOLUMNS('customer',"cid",'customer'[c_id])
return
COUNTX(
    FILTER(ALL('Baskets'),
    'Baskets'[c_id] in _column),[p_id])
Item_count =
var _customercid=SELECTCOLUMNS('customer',"cid",'customer'[c_id])
var _basketpid=SELECTCOLUMNS(FILTER('Baskets','Baskets'[c_id] in _customercid),"p_id",'Baskets'[p_id])
return
COUNTX(
    FILTER(all(Items),
    'Items'[p_id] in _basketpid),'Items'[item_category])

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @Analitika ,

 

You can try the following dax:

Baskets_count =
var _column=SELECTCOLUMNS('customer',"cid",'customer'[c_id])
return
COUNTX(
    FILTER(ALL('Baskets'),
    'Baskets'[c_id] in _column),[p_id])
Item_count =
var _customercid=SELECTCOLUMNS('customer',"cid",'customer'[c_id])
var _basketpid=SELECTCOLUMNS(FILTER('Baskets','Baskets'[c_id] in _customercid),"p_id",'Baskets'[p_id])
return
COUNTX(
    FILTER(all(Items),
    'Items'[p_id] in _basketpid),'Items'[item_category])

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ChiragGarg2512
Solution Sage
Solution Sage

This model might be the reason that there is an issue. Make the customer table, the main table and have many to one relationship with the other tables.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.