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
powerbi-help1
New Member

ALL Filter is causing column subtotal value to be incorrect

The following formula is pulling the correct value in the matrix but the column subtotal of the row is incorrect and only totaling the last value in the matrix row.

 

CALCULATE([Gross_Amount], FILTER(ALL(Periods), Periods[Index] = MAX(Periods[Index])-13))

 

The intentioion of the formula is have the current year period column headings ignored and then pull the previous year figures for the same period of time. IE P05 2021 ignored, data for P05 2020 pulled instead.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

 

 

[Measure] =
var VisiblePeriods = DISTINCT( Periods[Index] )
var PeriodsBack = 
    FILTER(
        ALL( Periods[Index] ),
        ( Periods[Index] + 13 ) in VisiblePeriods
    )
var Result = 
    CALCULATE(
        [Gross_Amount],
        PeriodsBack,
        // Depending on what you really want
        // your measure to do, you can include
        // this line below or exclude it:
        ALL( Periods )
    )
return
    Result

 

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

 

 

[Measure] =
var VisiblePeriods = DISTINCT( Periods[Index] )
var PeriodsBack = 
    FILTER(
        ALL( Periods[Index] ),
        ( Periods[Index] + 13 ) in VisiblePeriods
    )
var Result = 
    CALCULATE(
        [Gross_Amount],
        PeriodsBack,
        // Depending on what you really want
        // your measure to do, you can include
        // this line below or exclude it:
        ALL( Periods )
    )
return
    Result

 

 

I have made some additional changes to the formula, please see below.

 

var VisiblePeriods = DISTINCT( Periods[Index] )
var PeriodsBack =
FILTER(ALL(Periods),MAX(Periods[Index])-13 in VisiblePeriods)
var Result =
CALCULATE([Gross_Amount],PeriodsBack)
return
Result

 

This returns a zero value but no error, any advice on how to solve?

 

Thank you. 

Anonymous
Not applicable

There was a missing comma after PeriodsBack. I've corrected it above. Apart from this the formula works correctly when the model is set up the way I think it is. Since you have not shown the model... I had to imagine what it is. I can easily demonstrate that it does what it should.

Thank you, yes i was able utilize the formula to to produce the results as needed. 

Anonymous
Not applicable

Great 🙂

Thank you for the response. The formula did not work and returned a 0 value (after being edited to not have an error).

When I tried to use the result portion above as written and removed the //lines keeping the ALL (Periods) there was an error:

 

"The syntax for 'ALL' is incorrect. (DAX(var VisiblePeriods = DISTINCT( Periods[Index] )var PeriodsBack = FILTER( ALL( Periods[Index] ), ( Periods[Index] + 13 ) in VisiblePeriods )var Result = CALCULATE( [Gross_Amount], PeriodsBack ALL( Periods ) )return Result))."

 

Formula written as that produced error:

var VisiblePeriods = DISTINCT( Periods[Index] )
var PeriodsBack =
FILTER(
ALL( Periods[Index] ),
( Periods[Index] + 13 ) in VisiblePeriods
)
var Result =
CALCULATE(
[Gross_Amount],
PeriodsBack
ALL( Periods )
)
return
Result

 

Essentially I need the matrix to ignore the Year-Period columns and index from the CY period (ie P05 2021) to PY (P05 2020, hence the -13 on the index formula). My original formula I sent pulls each period but does not subtotal properly. 

 

 

Thank you.

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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