Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lsealy
Regular Visitor

Calculated column to compare current running total column to last activity date in previous month

Thank you for any help. Trying to get a calculated column 'Monthly_Change' that, for each row, subtracts the RT value on the last ActionDate in the previous month from the current RT value. Tried this, didn't work:

MonthlyChange = crf38_fieldactions[RT] - CALCULATE(SUM(crf38_fieldactions[RT]), LASTDATE(PREVIOUSMONTH(crf38_fieldactions[ActionDate])))

lsealy_1-1698241053892.png

 

 

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @lsealy ,

 

not sure if i fully get you, supposing you have a data table like:

date RT
9/1/2023 4
9/9/2023 4
9/17/2023 1
9/25/2023 2
10/3/2023 3
10/11/2023 2
10/19/2023 2
10/27/2023 6
11/4/2023 4

 

try to add a calculated column like:

column = 
VAR _prt=
MAXX(
    TOPN(
        1,
        FILTER(data, data[date]<=EOMONTH(EARLIER(data[date]), -1)),
        data[date]
    ),
    data[RT]
)
RETURN  
    IF(
        NOT ISBLANK(_prt), 
        [RT] - _prt
    )

 

it worked like:

FreemanZ_0-1698245659598.png

 

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @lsealy ,

 

not sure if i fully get you, supposing you have a data table like:

date RT
9/1/2023 4
9/9/2023 4
9/17/2023 1
9/25/2023 2
10/3/2023 3
10/11/2023 2
10/19/2023 2
10/27/2023 6
11/4/2023 4

 

try to add a calculated column like:

column = 
VAR _prt=
MAXX(
    TOPN(
        1,
        FILTER(data, data[date]<=EOMONTH(EARLIER(data[date]), -1)),
        data[date]
    ),
    data[RT]
)
RETURN  
    IF(
        NOT ISBLANK(_prt), 
        [RT] - _prt
    )

 

it worked like:

FreemanZ_0-1698245659598.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors