cancel
Showing results for
Did you mean:
Frequent Visitor

## DAX calculation of variable inside iterator SUMX

Hi guys!

I've been struggling with one case for more than week...

Input:

Table 'F_ERS_SellOut' with sales transactions.

Each row is fact of weekly sales [PostingDate] for one product [ProductCode] in specified store [StoreCode] .

I need to calculate [sales amount] of products with the price 20% lower than their regular price

I've stuck with regular price definition... Regular price is the max price [UnitPrice] of product in particular store for the last 70 days from "current" date [PostingDate]

My solution and thoughts (below attached code script too):

The measure always returns blank.

I realize that my mistake somewhere in calculation of Regular_price variable.

And also know that I have poor understanding of context transition inside nested iteartors so far...

I will be gratefully thankfull of brief explanation of what I'm doing wrong..

```Value_of_discounted_products =
SUMX(
FILTER(F_ERS_SellOut;
VAR Cur_Date = F_ERS_SellOut[PostingDate]
VAR Regular_price =
MAXX (
CALCULATETABLE (
ALL(F_ERS_SellOut[PostingDate]);
DATESINPERIOD ( 'Calendar'[Date]; Cur_Date; -70;DAY)
);
F_ERS_SellOut[UnitPrice]
)
RETURN
F_ERS_SellOut[UnitPrice] <= (Regular_price*0,8));
[Value])```
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team

## Re: DAX calculation of variable inside iterator SUMX

You may take a look at the post below.

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