Power BI: Using the Current Iterated Value in SUMX
- Can anyone tell me what I've done wrong? Like, am I modelling things completely wrong.
- Can you tweak my code so that is works?
I'm trying to have a Filter use the current value being evaluated in a parent SUMX. In pseudo code, I'm trying to do: (The ith value is the issue)
Sumx(
myDistinctValues
, Calculate(
myNumber
, Filter(
myFacts
, [myCat] =
)
)
)
I want to iterate over each row in myDistinctValues, use that value to Filter myFacts, and then return the sum. However, inside the Filter, it returns all rows; so my Measure throws an error.
My current DAX looks like this:
this_Measure =
var myFacts =
AddColumns(
,"myCat"
,
)
var myDistinctValues =
Distinct(
selectcolumns(
myFacts
, [myCat]
)
)
return
Sumx(
myDistinctValues
, Calculate(
myNumber
, Filter(
myFacts
, [myCat] = myDistinctValues
)
)
)