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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Cheryl314
New Member

Calculate difference every month in cumulative values

Hi All,

I'm a beginner - and I'm not a programmer.

I get a data dump each month of cumulative 'views' documents have received in a Sharepoint library.

This view count is from the time the document was uploaded on the system to date the report is extracted (lifetime views).

I need to be able to find that difference month-on-month and show those values.

 

SourceDocumentLifetime Views
Library 1 Mar 2024Document 110
Library 1 Mar 2024Document 22
Library 1 Mar 2024Document 38
Library 1 Mar 2024Document 417
Library 1 Mar 2024Document 516
Library 1 Mar 2024Document 68
Library 1 Apr 2024Document 422
Library 1 Apr 2024Document 517
Library 1 Apr 2024Document 616
Library 1 Apr 2024Document 756
Library 2 Feb 2024Document 849
Library 2 Feb 2024Document 921
Library 2 Mar 2024Document 1012
Library 3 Feb 2024Document 1114
Library 3 Feb 2024Document 123
Library 3 Feb 2024Document 131
Library 3 Feb 2024Document 149
Library 3 Mar 2024Document 1114
Library 3 Mar 2024Document 123
Library 3 Mar 2024Document 137
Library 3 Mar 2024Document 149
Library 3 Mar 2024Document 1515

 

So, eg: Document Document 4 had 17 lifetime views in Mar '24 & 22 in Apr '24, effectively having 5 new views in Apr '24.

Similarly, Document 14 had 9 views in both Mar & Apr - effectively showing 0 views in Apr.
That's the number I want to derive.

Appreciate any ideas!

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@Cheryl314 , You can use DAX for this

First create a new calculated column to extract month and year

MonthYear = FORMAT([Date], "MMM YYYY")

 

Second create a measure 

 

Difference =
VAR CurrentDocument = SELECTEDVALUE('Table'[SourceDocument])
VAR CurrentMonthYear = SELECTEDVALUE('Table'[MonthYear])
VAR PreviousMonthYear = CALCULATE(MAX('Table'[MonthYear]), 'Table'[SourceDocument] = CurrentDocument && 'Table'[MonthYear] < CurrentMonthYear)
VAR CurrentViews = CALCULATE(SUM('Table'[LifetimeViews]), 'Table'[SourceDocument] = CurrentDocument && 'Table'[MonthYear] = CurrentMonthYear)
VAR PreviousViews = CALCULATE(SUM('Table'[LifetimeViews]), 'Table'[SourceDocument] = CurrentDocument && 'Table'[MonthYear] = PreviousMonthYear)
RETURN IF(ISBLANK(PreviousMonthYear), 0, CurrentViews - PreviousViews)

 

Now create a matrix or table visualization using Measure

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

1 REPLY 1
bhanu_gautam
Super User
Super User

@Cheryl314 , You can use DAX for this

First create a new calculated column to extract month and year

MonthYear = FORMAT([Date], "MMM YYYY")

 

Second create a measure 

 

Difference =
VAR CurrentDocument = SELECTEDVALUE('Table'[SourceDocument])
VAR CurrentMonthYear = SELECTEDVALUE('Table'[MonthYear])
VAR PreviousMonthYear = CALCULATE(MAX('Table'[MonthYear]), 'Table'[SourceDocument] = CurrentDocument && 'Table'[MonthYear] < CurrentMonthYear)
VAR CurrentViews = CALCULATE(SUM('Table'[LifetimeViews]), 'Table'[SourceDocument] = CurrentDocument && 'Table'[MonthYear] = CurrentMonthYear)
VAR PreviousViews = CALCULATE(SUM('Table'[LifetimeViews]), 'Table'[SourceDocument] = CurrentDocument && 'Table'[MonthYear] = PreviousMonthYear)
RETURN IF(ISBLANK(PreviousMonthYear), 0, CurrentViews - PreviousViews)

 

Now create a matrix or table visualization using Measure

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors