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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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
v-yangliu-msft
Community Support
Community Support

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
v-yangliu-msft
Community Support
Community Support

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
Super User
Super User

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

October NL Carousel

Fabric Community Update - October 2024

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