Forum Discussion

NBU_FFF's avatar
NBU_FFF
Icon for Helper I rankHelper I
2 years ago
Solved

Help! 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...
  • Fowmy's avatar
    Fowmy
    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
        __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