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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
animebuff
Helper I
Helper I

dax in drilldown works without relationship

i have write a simple dax of subtraction and division and I have a region as drilldown

my requirement says to remove the relationship between dim country table and fact table so I removed it using CROSSFILTER 

since I remove the relationship my values for individual region is not right, all region inside a month year shows same value

ex. if month year nov 24 total is 200 

nov 24 asia is 100

nov 24 europe is 25

nov 24 NA is 50

nov 24 LA is 25

after removing the relationship using CROSSFILTER
in drilldown for all region ( asia, europe, NA and LA ), I get 200 

my requirement is to remove country region relationship at the same time the overall dax logic should work on drilldown

2 ACCEPTED SOLUTIONS
v-hashadapu
Community Support
Community Support

Hi @animebuff ,Thank you for reaching out to Microsoft Fabric Community Forum.


If the direct relationship between the dimCountry table and the fact table is removed, it will impact the filtering context, so now you see the same total for all regions.

We can use the TREATAS function to create a virtual relationship between the dimCountry table and the fact table. This way, we can eliminate the physical relationship while keeping the correct context for the calculations.


Sample Data:

dimCountry Table

vhashadapu_0-1734602792156.png

fact Table

vhashadapu_1-1734602841536.png

Total Value Measure:

Total Value =

VAR SelectedCountries = VALUES(dimCountry[Country])

RETURN

CALCULATE (

    SUM(fact[Value]),

    TREATAS(SelectedCountries, fact[Country])

)


Set up a Matrix Visual:

vhashadapu_2-1734602919764.png

 

Sample Output:

vhashadapu_3-1734602965745.png

If this helps, please mark it ‘Accept as Solution’, so others with similar queries may find it more easily. If not, please share the details.

View solution in original post

v-hashadapu
Community Support
Community Support

Hi @animebuff , Just checking in—were you able to resolve the issue?
If one of the replies helped, please consider marking it as "Accept as Solution" and giving a 'Kudos'. Doing so can assist other community members in finding answers more quickly.
Thank you!

View solution in original post

14 REPLIES 14
v-hashadapu
Community Support
Community Support

Hi @animebuff , Just checking in—were you able to resolve the issue?
If one of the replies helped, please consider marking it as "Accept as Solution" and giving a 'Kudos'. Doing so can assist other community members in finding answers more quickly.
Thank you!

sure will do it

v-hashadapu
Community Support
Community Support

Hi @animebuff , Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @animebuff , Hope your issue is solved. If it is, can you please consider marking it 'Accept as Solution'. Thank you.

animebuff
Helper I
Helper I

Requirement:

animebuff_0-1734608492944.png

left side visual is what by default we get in PBI
what I need is right side visual but the values of all region should not be 0.31 rather
apac - 1

europe - 0.5

la - 0.5

afracia - 1

australia - 1

na - 1

uae - 0

 

only apac, europe and la have both numerator and denominator so it should give respective values

uae only has denominator so it is 0 (0/anything)

rest regions doesn't have data so it should give value as 1

-----------------------------------------------------------------------------------------------------------------------

dax:

default dax = CALCULATE(COUNT('S rate'[success]),'S rate'[inclusion flag]="Y")/COUNT('S rate'[success])
 
modified dax = CALCULATE(CALCULATE(COUNT('S rate'[success]),'S rate'[inclusion flag]="Y")/COUNT('S rate'[success]),CROSSFILTER(region[region],'S rate'[region],None))
 ----------------------------------------------------------------------------------------------------------------------
tables

s rate

mkregioninclusion flagsuccess
1apacy95
1europen85
1lay91
1nan97
1african88
1australian95
1apacy93
2europey94
2lan89
2nan88
2african99
2australian80
2uaen90

 

region

region
apac
europe
la
na
africa
australia
uae

 

month

mkm
1nov
2dec
v-hashadapu
Community Support
Community Support

Hi @animebuff ,Thank you for reaching out to Microsoft Fabric Community Forum.


If the direct relationship between the dimCountry table and the fact table is removed, it will impact the filtering context, so now you see the same total for all regions.

We can use the TREATAS function to create a virtual relationship between the dimCountry table and the fact table. This way, we can eliminate the physical relationship while keeping the correct context for the calculations.


Sample Data:

dimCountry Table

vhashadapu_0-1734602792156.png

fact Table

vhashadapu_1-1734602841536.png

Total Value Measure:

Total Value =

VAR SelectedCountries = VALUES(dimCountry[Country])

RETURN

CALCULATE (

    SUM(fact[Value]),

    TREATAS(SelectedCountries, fact[Country])

)


Set up a Matrix Visual:

vhashadapu_2-1734602919764.png

 

Sample Output:

vhashadapu_3-1734602965745.png

If this helps, please mark it ‘Accept as Solution’, so others with similar queries may find it more easily. If not, please share the details.

Hi @animebuff , as the thread(post) in the link you have provided above is already taken up by another CST member, I am sorry to say i cannot work on it. If my answer to your original post helped your issue, please consider marking it 'Accept as Solution'. If not, please share the details so that we can work together to solve the issue.

Requirement:

animebuff_0-1734608492944.png

left side visual is what by default we get in PBI
what I need is right side visual but the values of all region should not be 0.31 rather
apac - 1

europe - 0.5

la - 0.5

afracia - 1

australia - 1

na - 1

uae - 0

 

only apac, europe and la have both numerator and denominator so it should give respective values

uae only has denominator so it is 0 (0/anything)

rest regions doesn't have data so it should give value as 1

-----------------------------------------------------------------------------------------------------------------------

dax:

default dax = CALCULATE(COUNT('S rate'[success]),'S rate'[inclusion flag]="Y")/COUNT('S rate'[success])
 
modified dax = CALCULATE(CALCULATE(COUNT('S rate'[success]),'S rate'[inclusion flag]="Y")/COUNT('S rate'[success]),CROSSFILTER(region[region],'S rate'[region],None))
 ----------------------------------------------------------------------------------------------------------------------
tables

s rate

mkregioninclusion flagsuccess
1apacy95
1europen85
1lay91
1nan97
1african88
1australian95
1apacy93
2europey94
2lan89
2nan88
2african99
2australian80
2uaen90

 

region

region
apac
europe
la
na
africa
australia
uae

 

month

mkm
1nov
2dec
Kedar_Pande
Super User
Super User

@animebuff 

Updated DAX Measure

Measure = 
VAR CurrentRegionFilter =
VALUES(DimCountry[Region])
RETURN
CALCULATE(
SUM(FactTable[Sales]),
TREATAS(CurrentRegionFilter, FactTable[Region])
)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

requirement:

animebuff_0-1734610567977.png

left side visual is what by default we get in PBI
what I need is right side visual but the values of all region should not be 0.31 rather
apac - 1

europe - 0.5

la - 0.5

afracia - 1

australia - 1

na - 1

uae - 0

 

only apac, europe and la have both numerator and denominator so it should give respective values

uae only has denominator so it is 0 (0/anything)

rest regions doesn't have data so it should give value as 1

 

-----------------------------------------------------------------------------------------------------------------------

dax:

 

default dax = CALCULATE(COUNT('S rate'[success]),'S rate'[inclusion flag]="Y")/COUNT('S rate'[success])
 
modified dax = CALCULATE(CALCULATE(COUNT('S rate'[success]),'S rate'[inclusion flag]="Y")/COUNT('S rate'[success]),CROSSFILTER(region[region],'S rate'[region],None))
 
-----------------------------------------------------------------------------------------------------------------------
 
tables:
 
s rate 
mkregioninclusion flagsuccess
1apacy95
1europen85
1lay91
1nan97
1african88
1australian95
1apacy93
2europey94
2lan89
2nan88
2african99
2australian80
2uaen90

 

region

region
apac
europe
la
na
africa
australia
uae

 

month

mkm
1nov
2dec
Ritaf1983
Super User
Super User

Hi @animebuff 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

animebuff_0-1734607679486.png

so left side visual is what by default we get in PBI
what I need is right side visual but the values of all region should not be 0.31 rather
apac - 1

europe - 0.5

la - 0.5

afracia - 1

australia - 1

na - 1

uae - 0

 

only apac, europe and la have both numerator and denominator so it should give respective values

uae only has denominator so it is 0 (0/anything)

rest regions doesn't have data so it should give value as 1

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.