March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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.
Solved! Go to Solution.
[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
[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.
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.
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:
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
23 | |
15 | |
12 | |
9 | |
8 |
User | Count |
---|---|
41 | |
32 | |
29 | |
12 | |
12 |