cancel
Showing results 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

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?

1 ACCEPTED SOLUTION
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.
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.

Announcements

#### 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 Monthly Update - June 2024

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

#### New forum boards available in Real-Time Intelligence.

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

Top Solution Authors
Top Kudoed Authors