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
Hello,
I have a dataset that contains Sales data. It has the following columns :
I want set up a table widget with 2 columns :
Step 1) Calculate the sum of quantities per Period_id, for each Period_id starting from (Period_id - 4) to Period_id of the current row.
Step 2) Then calculate the average of the 4 sums previously calculated.
Obviously, the dataset can be also filtered with slicers on Country_id, Product_id, ...
Could you help me to write the DAX formula to perform this complex calculation ?
Thanks !
Best Regards
Solved! Go to Solution.
THanks wdx223_Daniel for you reply.
I have a question in order to understand deeper :
if I refer to the DAX documentation, AVERAGEX accept, as a 1st argument, a table or an expression that specifies the table over which the aggregation can be performed.
Your 1st argument for AVERAGEX if a TOPN function : TOPN(4, FILTER(...)).
This TOPN function return a table with a single column : 'Period'[Period_id] ; and it contains no column with Quantities.
So my question is : How can AVERAGEX function extract the average from this table that has only one column and no quantity values / scalar values ?
Regards
@jct999 this about context transition
when you refer a measure in the 2nd parameter of a iterator, the context transition happens. it will transform the row context brought in by 1st parameter of the iterator into filter context and then use it to calculate the measure.
that is the AVGERAGEX generate a row context of period id, and tranform it to filter context, then used it in the calculation of [QTY Total].
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
14 | |
11 | |
8 | |
5 |
User | Count |
---|---|
26 | |
21 | |
20 | |
14 | |
10 |