I have this code below and what I am trying to do is stop it from doing a calculation when the Branch name is blank which works in the table
newAverageBays =
IF (
SELECTEDVALUE ( 'Overview Table'[branch_type] ) = "ONLINE",
0,
IF (SELECTEDVALUE('Branch Table'[branch_name]) = BLANK(),0,
COALESCE (
CALCULATE (
SUM ( 'Range Plan Table'[number_bays] ),
USERELATIONSHIP ( 'Overview Table'[campaignStartDate], 'Range Plan Table'[range_plan_date] ) --CROSSFILTER( 'Range Plan Table'[range_name], 'Range Table'[Range Name], BOTH)
),
0
)
)
)
The thing is that it causes another DAX measure to not work and returns a 0 for this:
AvgBays v2 =
COALESCE(CALCULATE (
AVERAGEX (
VALUES ( 'Overview Table'[campaign] ),
[newAverageBays]
),
REMOVEFILTERS ('Overview Table'[No Dimension] )
),0)
Is there a way to do this without breaking any of my other measures?


I found a solution by adding a filter within the actual calculate function like so: