Forum Discussion
NBU_FFF
Helper I
2 years agoHelp! How to get the data from previous month
Dear Community, I'm struggled to get the data from previouis month in Power BI . My case is we need to get 202401 fianl qty as the input of 202402 ini qty. How to give DAX to show 9 & 19 as below re...
- 2 years ago
NBU_FFF
Here is the solution:Initial Value = VAR __WH = 'Table'[WH] VAR __Month = 'Table'[Month] VAR __T = FILTER( 'Table', 'Table'[WH] = __WH && 'Table'[Month] < __Month ) VAR __Result = SUMX( __T ,'Table'[In] - 'Table'[Out] ) RETURN __ResultMonth End = VAR __WH = 'Table'[WH] VAR __Month = 'Table'[Month] VAR __T = FILTER( 'Table', 'Table'[WH] = __WH && 'Table'[Month] <= __Month ) VAR __Result = SUMX( __T ,'Table'[In] - 'Table'[Out] ) RETURN __Result
NBU_FFF
Helper I
2 years agoFowmy Very sorry for the typo. Just sticking on that. I've corrected it as should be:
If you think it is necessary to add other column pls advise or update on my shared file.
https://1drv.ms/u/s!AhkI23dIWO7yiUo2qB9womv65ZDB?e=lpkS4R
Thanks again.
Fowmy
Super User
2 years agoNBU_FFF
Here is the solution:
Initial Value =
VAR __WH = 'Table'[WH]
VAR __Month = 'Table'[Month]
VAR __T =
FILTER(
'Table',
'Table'[WH] = __WH && 'Table'[Month] < __Month
)
VAR __Result = SUMX( __T ,'Table'[In] - 'Table'[Out] )
RETURN
__Result
Month End =
VAR __WH = 'Table'[WH]
VAR __Month = 'Table'[Month]
VAR __T =
FILTER(
'Table',
'Table'[WH] = __WH && 'Table'[Month] <= __Month
)
VAR __Result = SUMX( __T ,'Table'[In] - 'Table'[Out] )
RETURN
__Result