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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Writing out expression gives different result than inserting the measure that is exactly the same?

Hey guys i'm learning dax. I wrote this measure on training data= 

Average Quantity Sold per Day = AVERAGEX(VALUES(Dates[Date]);[Total Quantity Sold])
When I drag this expression in the visualisation canvas, I get the result 26,03. So far, so good.
Now here's the weird thing. The second argument, [Total Quantity Sold], is written like this (i'm just copypasting my measures here)=
Total Quantity Sold = SUM(Sales[Quantity])
I wanted to replace my measure reference in the averagex measure by the full written expression instead of the measure name to better help me understand what is happening, so I wrote:
Average Quantity Sold per Day = AVERAGEX(VALUES(Dates[Date]);SUM(Sales[Quantity]))
Now after pressing enter, my visualisation (which just gives the value in a one row, one column table i.e. I just the 'table' visualisation to check my result) gives 9528,00?? Either i'm missing something simple or I do not understand DAX behavior at all. The second Average Quantity Sold per Day expression is just the first one with the name for my measure written as an expression, so how is it giving different results? 
 
Thanks in advance!
 
 
 
1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi @Anonymous 

Since Total Quantity Sold = SUM(Sales[Quantity])

In the Measure [Average Quantity Sold per Day], It nested a measure [Total Quantity Sold].

Average Quantity Sold per Day = AVERAGEX(VALUES(Dates[Date]);[Total Quantity Sold]) ,

So it essentially looks like this formula 

Average Quantity Sold per Day=AVERAGEX(VALUES('Date'[Date]); CALCULATE(SUM(Sales[Quantity])) )

not this formula Average Quantity Sold per Day = AVERAGEX(VALUES(Dates[Date]);SUM(Sales[Quantity]))

 

Please refer to CALCULATE Function in dax

https://docs.microsoft.com/en-us/dax/calculate-function-dax

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-lili6-msft
Community Support
Community Support

hi @Anonymous 

Since Total Quantity Sold = SUM(Sales[Quantity])

In the Measure [Average Quantity Sold per Day], It nested a measure [Total Quantity Sold].

Average Quantity Sold per Day = AVERAGEX(VALUES(Dates[Date]);[Total Quantity Sold]) ,

So it essentially looks like this formula 

Average Quantity Sold per Day=AVERAGEX(VALUES('Date'[Date]); CALCULATE(SUM(Sales[Quantity])) )

not this formula Average Quantity Sold per Day = AVERAGEX(VALUES(Dates[Date]);SUM(Sales[Quantity]))

 

Please refer to CALCULATE Function in dax

https://docs.microsoft.com/en-us/dax/calculate-function-dax

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

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