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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PPerera
New Member

Switch statement creates a cross join. Want to understand ways to rectify issue

Hi All

 

PPerera_3-1759777930521.png

 

I have a WAVG metric created using following definition.

 

WA1 =
SUMX( 'public fsales',  'public fsales'[sales]*RELATED('public strrtg1'[rtgfactor]))
/
SUM('public fsales'[sales])
 

The definition involves two tables and a connection has established as shown below

 

'public fsales' [rtg] = 'public strrtg1' [rtg]

 

PPerera_0-1759777183398.png

 

In 'public strrtg1'  , [rtg] and [rtgfactor] has 1 : 1 relationship

 

** When I add WA1 to a grid with other few attributes , no additional rows get produced so I do not notice a cross join effect.

 

I created a calculated measure in  'public strrtg1'  using SWITCH statemnet as shown below

 

WA2 = SWITCH (
TRUE,
'public fsales'[WA1] <=120 , "A+",
'public fsales'[WA1] <=175, "A",
'public fsales'[WA1] <=1500, "A-",

'public fsales'[WA1] <=2300, "B+",

'public fsales'[WA1] <=3400, "B",

'public fsales'[WA1] <=4100, "B-",

"N/A"
)

 

When I add WA2 to the grid with few attributes, large number of rows get generated and looks like it is doing a cross join 

 

Eg 1: no cross join 

PPerera_1-1759777342210.png

Eg 2 : there is cross join

 

PPerera_2-1759777551729.png

 

Please help me to solve this issue

 

Thank you

1 REPLY 1
samratpbi
Super User
Super User

Hi,

 

Looking into the screenshot, it seems more number of rows is getting returned due to 1. you have introduced prodname column and also while calculating W2, you didnt handle blank. Add a condition when WA1 is blank.

 

Helpful resources

Announcements
Users online (27)