Problem in relationship between tables

LearnMeExcel

Well-known Member
Joined
Aug 11, 2009
Messages
746
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi

i need help in this issue
i have 4 Tables:
1. SalesDB : contains All Data for My Invice --> i have column named "CustCod"
2. CustomerDB : all Customer info more than 15000 Rows --> i have column named "CustCod" , i connect SalesDB with CustomerDB by this Col
3. GiftDB : contains the custome who get gift from our SalesRep "some customer get more than 1 gift, that is mean more than one row for him " --> this table Conect with CustomerDB
4. TabDB : contains the custome who have Tables for our Products"some customer get more than 1 Table, that is mean more than one row for him " --> this table Conect with CustomerDB

what i work on, i want to know the customers who Get Gifts, and the Custome who have tables
in CustomerDB i add new Column to make Calucalted column by this DAX
=RELATED(GiftDB[CustCod])
but i get Error " The Column 'GiftDB[CustCod]' either doesn't exits or doesn't have relationship to any aviable in the current context"
============
i reviewd all relationship between tables it ok and all of this relationships are active

what is my problem
or how i can't solve this issues to get the customer who have gifts or table
any idea please
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
No idea
By another way
If I use normal excel I will use COUNTIF
=if(countif(giftdb[cusCod],CustomerDb[activeCell]),1,0)

How I can make same formula in customer table to know if have gift
 
Upvote 0
If I understand your layout correctly, your formula won't work because the relationship is in the other direction. I would approach the problem by adding 2 columns to the CustomerDB:
GiftCount:=calculate(countrows(Giftdb),filter(Giftdb,Giftdb[CustCod]=CustomerDB[CustCod]))
TabCount:=calculate(countrows(Tabdb),filter(Tabdb,Tabdb[CustCod]=Customerdb[CustCod]))

Note that these formulas do not leverage any existing relationships. They are evaluated when the model is loaded (not on user slice/dice) thus could be sluggish to load, but fast to pivot on.

Depending on your reporting needs you can now pivot on the CustomerDB table, or first create another column in CustomerDB that acts as a flag (if(GiftCount>1 && TabCount>2,"GoodCust",blank()) or something similar.

This kind of approach bothered me in the past as I am very much a star schema traditionalist, with calculations in the fact table and filtering by dimensions - and this approach is the opposite. Long story short... I got over it...
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top