Forum Discussion
I Need a Measure not a Power Query Formula - Accumulative column
- 5 years ago
Hi mhrkhader01 ,
You can try the next option:
Create these measures:
#Accum = VAR currentDate = SELECTEDVALUE ( T[Date] ) VAR sumAmt = CALCULATE ( SUM ( T[Diff] ), FILTER ( ALLSELECTED ( T ), T[Date] <= currentDate ) ) RETURN sumAmt#AccumFiltered = VAR currentDate = SELECTEDVALUE ( T[Date] ) VAR firstDatValue = MINX ( ALLSELECTED ( T ), T[Date] ) VAR minValue = MINX ( FILTER ( T, T[Date] = firstDatValue ), T[Diff] ) VAR sumAmt = CALCULATE ( SUM ( T[Diff] ), FILTER ( ALLSELECTED ( T ), T[Date] <= currentDate ) ) VAR minOfSum = MIN ( 0, MINX ( FILTER ( ALLSELECTED ( T ), T[Date] <= currentDate ), [Accum] ) ) RETURN IF ( currentDate = firstDatValue && minValue < 0, sumAmt - minValue, sumAmt - minOfSum )If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.
- 5 years ago
You can use MAX instead of SELECTEDVALUE .
If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.
Hi mhrkhader01 ,
You can try the next option:
Create these measures:
#Accum =
VAR currentDate = SELECTEDVALUE ( T[Date] )
VAR sumAmt =
CALCULATE (
SUM ( T[Diff] ),
FILTER ( ALLSELECTED ( T ), T[Date] <= currentDate )
)
RETURN sumAmt
#AccumFiltered =
VAR currentDate = SELECTEDVALUE ( T[Date] )
VAR firstDatValue = MINX ( ALLSELECTED ( T ), T[Date] )
VAR minValue = MINX ( FILTER ( T, T[Date] = firstDatValue ), T[Diff] )
VAR sumAmt =
CALCULATE (
SUM ( T[Diff] ),
FILTER ( ALLSELECTED ( T ), T[Date] <= currentDate )
)
VAR minOfSum =
MIN (
0,
MINX ( FILTER ( ALLSELECTED ( T ), T[Date] <= currentDate ), [Accum] )
)
RETURN
IF (
currentDate = firstDatValue && minValue < 0,
sumAmt - minValue,
sumAmt - minOfSum
)
If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.
Dear ERD,
im writing this in PowerPivot , not in PowerBI. SELECTEDVALUE is not coming with me in DAX. if you have Excel file could you please share it . it will be appreciated. or if you can provide me with another function instead of using SELECTEDVALUE for PowerPivot.
- ERD5 years ago
Community Champion
You can use MAX instead of SELECTEDVALUE .
If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.
- mhrkhader015 years ago
Helper I
Dear ERD, i have a Question.
suppose i have in PowerPivot 20 Measures, what i want is that whenever i drag the measure , any of the 20 Measures to Values Section in Pivot Table, i need that Measure to be divided by 12. how to do that. so the final result in Pivot Table for that Measure is tthe result of dividing the measure by 12. is that Possible? without changing all 20 Measures formulas.
- ERD5 years ago
Community Champion
I believe this can be achieved by using Calculation groups.
Here is what you can read on this: https://dax.guide/selectedmeasure/ (article with references).