Return 0 if name of row is BLANK

26 views Asked by At

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
        )
    )
)


enter image description here

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)

enter image description here

Is there a way to do this without breaking any of my other measures?

1

There are 1 answers

0
jcoke On

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

FILTER('Branch Table', 'Branch Table'[branch_name] <> BLANK()),