Forum Discussion
DAX: Rollup value within a group
- 8 years ago
Hi lacq
First add a calculated column in your FactValues
Use this Column in the Visual
CountryName = related(DimCountry[CountryName])
Now you can use this MEASURE to get the Cumulative
Cumulative = CALCULATE ( SUM ( FactValues[Value] ), FILTER ( ALLEXCEPT ( FactValues, FactValues[CountryName] ), FactValues[Date] <= SELECTEDVALUE ( FactValues[Date] ) ) )
Hi lacq
First add a calculated column in your FactValues
Use this Column in the Visual
CountryName = related(DimCountry[CountryName])
Now you can use this MEASURE to get the Cumulative
Cumulative =
CALCULATE (
SUM ( FactValues[Value] ),
FILTER (
ALLEXCEPT ( FactValues, FactValues[CountryName] ),
FactValues[Date] <= SELECTEDVALUE ( FactValues[Date] )
)
)Excellent Zubair_Muhammad, it works like a charm..... Well done!!!!
Now imagine that I've another group by, e.g. City_Name... how can I change the DAX to manage it, i.e.
Thanks in advance, lacq
- Zubair_Muhammad8 years ago
Community Champion
- lacq8 years agoRegular Visitor
Hi Zubair_Muhammad,
I'm sorry I didn't explain myself well.... when I said that I have a new "group by", City_name, I would like to maintain the Country Name Group... maybe the City_Name was a bad example... let's try with ProductName, so the same product might be sold in different countries.. and I would like to roll up the value by Country_Name and Product_Name .
Thanks again, lacq
- Zubair_Muhammad8 years ago
Community Champion
In that case, I believe you will just need to extend the
ALLEXCEPT ( FactValues, FactValues[CountryName] )
to
ALLEXCEPT ( FactValues, FactValues[CountryName], FactValues[ProductName] )