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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
orlando9427
Frequent Visitor

Ignore relationship on single case of switch

Hi,

 

I'm trying to apply differents filtering criteria depending on sales division, thanks to amitchandak and the SUMX/SWITCH functions I'm able to apply as intended, but one division generates a problem.

My model contains three tables as follows:

DIVISIONDIVISION_NAME
1B2B
2B2C
3SHOP

 

SALESMANDIVISION_IDSALESMAN_NAME
11John
22Peter
31Claire

 

TOTAL_PRICESALESMAN_IDIN_SHOPARTICLEAB
10001YA11
20001NB22
15002YC22
25003YD12
1000-1YE11

 

IDs are linked in a one to many relationship, so I can graph sales per division and per salesman using this code.

 

 

 

MTD = SUMX(
   VALUES(DIVISIONS[DIVISION]), 
   SWITCH(
      DIVISIONS[DIVISION], 
      1, CALCULATE(SUM(SALES[TOTAL_PRICE]),
         FILTER(SALES, SALES[A] = 1)),
      2, CALCULATE(SUM(SALES[TOTAL_PRICE]),
         FILTER(SALES, SALES[A] = 2 && SALES[B] = 2)),
      3, CALCULATE(SUM(SALES[TOTAL_PRICE]),
         FILTER(SALES, SALES[IN_SHOP] = "Y"),
      0
   )
)

 

 

 

 

The SHOP division can be generated by division B2B and B2C and also in its own, but both divisions are filtered when graphed vs division and salesman, also tried to disable the relationship and add USERELATIONSHIP on case 1 and 2 but it generate a constant value that is added to all division, is there a way to disable relationship just in case 3?

 

The intended behavior is to get the following.

DIVISIONSALES
B2B3500
B2C1500
SHOP6000

 

Thanks in advantage

1 REPLY 1
amitchandak
Super User
Super User

@orlando9427 , Modify Measure as , file is attached with correct reltionship

 

amitchandak_0-1698376818381.png

 

You can use crossjoin with None to disable the join

 

Create a measure

MTD = 
Var _tab = ALLSELECTED(SALESMAN[SALESMAN])
return
SUMX(
   VALUES(DIVISION[DIVISION]), CALCULATE(
   SWITCH(
      max(DIVISION[DIVISION]), 
      1, CALCULATE(SUM(SALES[TOTAL_PRICE]),
         FILTER(SALES, SALES[A] = 1 && SALES[SALESMAN_ID] in _tab && SALES[IN_SHOP] = "Y")),
      2, CALCULATE(SUM(SALES[TOTAL_PRICE]),
         FILTER(SALES, SALES[A] = 2 && SALES[B] = 2 && SALES[SALESMAN_ID] in _tab && SALES[IN_SHOP] = "Y")),
      3, CALCULATE(SUM(SALES[TOTAL_PRICE]),
         FILTER(SALES, SALES[IN_SHOP] = "Y")),
      0
   )
))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.