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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.