Forum Discussion

darylmc's avatar
darylmc
Frequent Visitor
5 years ago
Solved

Measure showing zero when not filtered

I'm looking to show a measure to the same week in the previous fiscal year:     LY Stock (sgls) = VAR currentFiscalYear = MAX ( 'Stock & Sales'[fiscal_year] ) VAR currentFiscalWeek = MAX...
  • mahoneypat's avatar
    5 years ago

    Please try this expression instead.  Not sure why you have the ALLSELECTED() in there and then filter it back down again with SELECTEDVALUE.  In any case, the SELECTEDVALUE is why you were not seeing anything for total.  I replaced it with VALUES.  Also note that I updated your ALL to only include the columns being filtered (a good practice).

     

    LY Stock (sgls) =
    VAR currentFiscalYear =
        MAX ( 'Stock & Sales'[fiscal_year] )
    VAR currentFiscalWeek =
        MAX ( 'Stock & Sales'[fiscal_week_number] )
    RETURN
        CALCULATE (
            SUM ( 'Stock & Sales'[stock_sgls] ),
            ALLSELECTED ( 'Stock & Sales'[bu] ),
            FILTER (
                ALL (
                    'Stock & Sales'[fiscal_year],
                    'Stock & Sales'[fiscal_week_number]
                ),
                'Stock & Sales'[fiscal_year] = currentFiscalYear - 1
                    && 'Stock & Sales'[fiscal_week_number] = currentFiscalWeek
            ),
            VALUES ( 'Stock & Sales'[bu] )
        )

    Regards,

    Pat