Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I am doing some averaging computations, and my computations seems to be quite off. I just want to ask for correction on why my measure doesnt seem to work. My data are as follows :
On my Masterlist table:
Borrower Attribute Date Value
ABC Loan 1/1/2019 1000
ABC Collection 1/5/2019 300
ABC Loan 2/5/2019 3000
My measures were as follows :
Solved! Go to Solution.
Hi, @jmcph , the cause of problem lies in leveraging a variable within iteration.
In fact, variable in DAX is NOT always variable, refer to:
https://radacad.com/caution-when-using-variables-in-dax-and-power-bi
In DAX, variables are calculated within the scope in which they are written, and then the result of them is stored and used in the rest of the expression.
To be more precise with your issue, when AVERAGEX iterates All( 'Calendar'[Date]) (being "1/1", "1/5", "2/5"), SumLoan is used 3 times with the same value, which is calculated on iterating "1/1". Furthermore, SumLoan is define in the outmost scope of the measure, only initial filter context instead of "1/1", such as slicer, row/column of viz etc., is used in the calculation.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi, @jmcph , the cause of problem lies in leveraging a variable within iteration.
In fact, variable in DAX is NOT always variable, refer to:
https://radacad.com/caution-when-using-variables-in-dax-and-power-bi
In DAX, variables are calculated within the scope in which they are written, and then the result of them is stored and used in the rest of the expression.
To be more precise with your issue, when AVERAGEX iterates All( 'Calendar'[Date]) (being "1/1", "1/5", "2/5"), SumLoan is used 3 times with the same value, which is calculated on iterating "1/1". Furthermore, SumLoan is define in the outmost scope of the measure, only initial filter context instead of "1/1", such as slicer, row/column of viz etc., is used in the calculation.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Proud to be a Super User!
Yeah. Thanks for the input. I think i'll do normal average calculation first, then make another measure filtering the dates to make it simpler. I appreciate it thanks!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
68 | |
53 | |
39 | |
33 |
User | Count |
---|---|
70 | |
63 | |
57 | |
49 | |
46 |