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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
jh292
Helper I
Helper I

Calculating change in data between two report dates within the same sheet

Hi

 

New to powerBI, hopefully a quick fix. 

 

I have a table that I need to make a messure for (I think) to show me the change over a period of time. Ideally that I can adapt / copy paste so I can create messures for 7 days 30 days 90 days etc. 

 

The table is created using Combined Files from reports loaded ad-hocly (sometimes daily some times weekly)

The table shows data that my team have captured from our customers. It calculates the number of insight items they have collected and returns a total "Known Insight" value for each customer.

 

I want to be able to show the change over a given period of time, ideally dynamically so I dont have to do anything exect keep refreshing reports into the power BI and topping up the sheet!


Here is my table. 

Source.NameNameKnown InsightReport Date
Site - Insight 07.10.2020.csvCustomer A407-Oct-20
Site - Insight 07.10.2020.csvCustomer B407-Oct-20
Site - Insight 07.10.2020.csvCustomer C407-Oct-20
Site - Insight 05.10.2020.csvCustomer A405-Oct-20
Site - Insight 05.10.2020.csvCustomer B305-Oct-20
Site - Insight 05.10.2020.csvCustomer C205-Oct-20
Site - Insight 27.9.2020.csvCustomer A127-Sep-20
Site - Insight 27.9.2020.csvCustomer B127-Sep-20
Site - Insight 27.9.2020.csvCustomer C127-Sep-20


If I had a message to calculate insight gathered in the last 2 days the answer would be 3 (none from customer a, 1 from customer b and 2 from customer c)

The dates that the reports are sourced will change so I believe the messure is something to do with the total from the latest report (within the last 2 days) minus the next report after the date range (2days). that way if I havent run a report for two days the answer is 0. But IF I run a messure for 90 days I want the lastest report (within 90days) minus the next report out side of the 90 days (possible 92 days for example) 

The Report Date field has a relationship to a date table shown below (starts at 2017 but runs through till well have 2025;

 

 

DateYearQuarterOfYearMonthOfYearDayOfMonthMonth NameMonth & YearQuarterInCalendarDayInWeekDayOfWeekNameWeekEndingWeek NumberMonth Year SortQrt in Year SortShortYearFYQuartersSales Year QuarterSales Quarter & Year
03 July 20172017373JulyJul 2017Q3 20170Monday########28201707002017030017FY18Q3Q2Q2 2018
04 July 20172017374JulyJul 2017Q3 20171Tuesday########28201707002017030017FY18Q3Q2Q2 2018

 

Oh my! help please!

Many thanks

 

James

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jh292 

I build a table like yours to have a test.

1.png

To calculate insight gathered in the last 2 days, firstly calculate the Maxdate1(2020/10/13) within last 2 days and then calculate the Maxdate2 which is before Maxdate1(2020/10/11).

Measure:

Measure = 
VAR _Max2Days =
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            DATEDIFF ( 'Table'[Report Date], TODAY (), DAY ) <= 2
        ),
        'Table'[Report Date]
    )
VAR _MaxMinus =
    MAXX (
        FILTER ( ALL ( 'Table' ), 'Table'[Report Date] < _Max2Days ),
        'Table'[Report Date]
    )
VAR _SumA =
    SUMX (
        FILTER ( 'Table', 'Table'[Report Date] = _Max2Days ),
        'Table'[Known Insight]
    )
VAR _SumB =
    SUMX (
        FILTER ( 'Table', 'Table'[Report Date] = _MaxMinus ),
        'Table'[Known Insight]
    )
RETURN
    _SumA - _SumB

 Result is A: 6-5=1,B:6-6=0,C:5-4=1 sum=2.

2.png

You can download the pbix file from this link: Calculating change in data between two report dates within the same sheet

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@jh292 , Not very clear, but with date table, you can try

 

Rolling 30= CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],staroffmonth(Sales[Sales Date]),-30,day))

Rolling 30 to 60 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max(dateadd('Date'[Date],-30,day)),-30,day))

 

Rolling 3= CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],staroffmonth(Sales[Sales Date]),-3,day))

Rolling 3 to 6 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max(dateadd('Date'[Date],-3,day)),-3,day))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Affraid that still just totals everything regardless of date.... 

Thanks for trying!

Anonymous
Not applicable

Hi @jh292 

I build a table like yours to have a test.

1.png

To calculate insight gathered in the last 2 days, firstly calculate the Maxdate1(2020/10/13) within last 2 days and then calculate the Maxdate2 which is before Maxdate1(2020/10/11).

Measure:

Measure = 
VAR _Max2Days =
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            DATEDIFF ( 'Table'[Report Date], TODAY (), DAY ) <= 2
        ),
        'Table'[Report Date]
    )
VAR _MaxMinus =
    MAXX (
        FILTER ( ALL ( 'Table' ), 'Table'[Report Date] < _Max2Days ),
        'Table'[Report Date]
    )
VAR _SumA =
    SUMX (
        FILTER ( 'Table', 'Table'[Report Date] = _Max2Days ),
        'Table'[Known Insight]
    )
VAR _SumB =
    SUMX (
        FILTER ( 'Table', 'Table'[Report Date] = _MaxMinus ),
        'Table'[Known Insight]
    )
RETURN
    _SumA - _SumB

 Result is A: 6-5=1,B:6-6=0,C:5-4=1 sum=2.

2.png

You can download the pbix file from this link: Calculating change in data between two report dates within the same sheet

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors