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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.