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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.