cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tusmo Regular Visitor
Regular Visitor

Confusing DAX measure behavior

Hi,

 

Sorry for the vague variable names but I'd rather not reveal too many details. I'm kind of new to DAX and the problem I'm having is that I have defined a measure that looks like this:

 

SUMX(Table;
  VAR var_1 = CALCULATE([measure_1])
  VAR var_2 = CALCULATE([measure_2])

  RETURN var_1 * var_2

)

 

So basically for each row of Table I want to calculate measures_1 and measure_2 after transitiong the row context into a filter context and then multiply them. My problem is that right now this measure is always giving me BLANK. However if I define measure:

 

SUMX(Table;
  VAR var_1 = CALCULATE([measure_1])
  VAR var_2 = CALCULATE([measure_2])

  RETURN var_1

)

 

Everything works fine, and if I do: 

 

SUMX(Table1;
  VAR var_1 = CALCULATE([measure_1])
  VAR var_2 = CALCULATE([measure_2])

  RETURN var_2

)

 

Everything also works fine. Fine meaning that both measures return non-BLANK decimal values when the original only returns BLANK. This goes against everything I thought I understood about DAX. How can both var_1 and var_2 seem to evaluate to non-BLANK values in the exactly same context but when I take the product everything goes BLANK?

 

1 REPLY 1
Barnee Regular Visitor
Regular Visitor

Re: Confusing DAX measure behavior

Hi @tusmo,

since I don't really see the context of the calc here it's going to be a blind guess based on the syntax of the calc.

I might would try to define the variables at the begining of the calc and then write the SUMX part after the RETURN
Like this:

Measure 3 = VAR var1 = CALCULATE([Measure])
            VAR var2 = CALCULATE([Measure 2])
RETURN
SUMX(Table1,var1*var2)

Bests,

Barna

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors (Last 30 Days)