mgirvin
Well-known Member
- Joined
- Dec 15, 2005
- Messages
- 1,245
- Office Version
- 365
- Platform
- Windows
Note: I recently posted my DAX Formula question at the Microsoft Power BI Forums (https://community.powerbi.com/t5/Forums/ct-p/Forums) and had a really bad experience (my post was marked as spam and I could not get help with the issue)... So I am going to try here at mrexcel.com, where I have had great experiences over the years : )
DAX Iterator Efficiency: Formula or Measure in Second Argument of AVERAGEX?
Dear Team,
I have a Fact Table named fTransactions with 3,360 rows.
I have created this Measure to sum the Transactional Line Item Revenue from a Fact Table:
Measure [1] is as follows:
Total Revenue :=
SUMX (
fTransactions,
ROUND ( RELATED ( dProduct[RetailPrice] ) * fTransactions[Units], 2 )
)
Next, I would like to create a Measure to average the Transactional Line Item Revenue from a Fact Table. But my question is: “Should I use a Measure in the second argument of AVERAGEX or repeat the formula?” The two measures I am considering are listed here:
Measure [2] is as follows:
Ave Transactional Rev 2nd is Formula :=
AVERAGEX (
fTransactions,
ROUND ( RELATED ( dProduct[RetailPrice] ) * fTransactions[Units], 2 )
)
Measure [3] is as follows:
Ave Transactional Rev 2nd is Measure :=
AVERAGEX ( fTransactions, [Total Revenue] )
I am asking this question because it seems to me that in Measure [3] there are two iterations over the Fact Table, and maybe this is inefficient?
When I run the two formulas in DAX Studio to time and look at query plan (I am a novice at reading all this), I can see:
Measure [2]
Measure [3]
There are other details in DAX Studio too. But it seems to me like the DAX Studio information is suggesting that Measure [3] with the Measure in the second argument of AVERAGEX has to work harder.
Any ideas that can help me to understand more completely which version to use for calculating the average of the Transactional Line Item Revenue? Measure [2] or Measure [3]?
DAX Iterator Efficiency: Formula or Measure in Second Argument of AVERAGEX?
Dear Team,
I have a Fact Table named fTransactions with 3,360 rows.
I have created this Measure to sum the Transactional Line Item Revenue from a Fact Table:
Measure [1] is as follows:
Total Revenue :=
SUMX (
fTransactions,
ROUND ( RELATED ( dProduct[RetailPrice] ) * fTransactions[Units], 2 )
)
Next, I would like to create a Measure to average the Transactional Line Item Revenue from a Fact Table. But my question is: “Should I use a Measure in the second argument of AVERAGEX or repeat the formula?” The two measures I am considering are listed here:
Measure [2] is as follows:
Ave Transactional Rev 2nd is Formula :=
AVERAGEX (
fTransactions,
ROUND ( RELATED ( dProduct[RetailPrice] ) * fTransactions[Units], 2 )
)
Measure [3] is as follows:
Ave Transactional Rev 2nd is Measure :=
AVERAGEX ( fTransactions, [Total Revenue] )
I am asking this question because it seems to me that in Measure [3] there are two iterations over the Fact Table, and maybe this is inefficient?
When I run the two formulas in DAX Studio to time and look at query plan (I am a novice at reading all this), I can see:
Measure [2]
- Physical Query Plan has 16 lines
- The largest number of records in the Physical Plan is 1
- For the Server Timings: FE = 1 ms and SE = 1 ms
- In the Server Query Tab I see one Query
Measure [3]
- Physical Query Plan has 19 lines
- The largest number of records in the Physical Plan is 3,360
- For the Server Timings: FE = 2 ms and SE = 2 ms
- In the Server Query Tab I see two Queries
There are other details in DAX Studio too. But it seems to me like the DAX Studio information is suggesting that Measure [3] with the Measure in the second argument of AVERAGEX has to work harder.
Any ideas that can help me to understand more completely which version to use for calculating the average of the Transactional Line Item Revenue? Measure [2] or Measure [3]?