Reply
habibsyed01
Regular Visitor

Accessing Previous records!

Hello Everyone!

 

Scenario

Here is my situation. I have a table/view that records every transaction. In Power BI I have aggregated the table to show summary for each day for last 8 days. I have a requirement to compute the growth in total consultations by comparing the total consultation for a specific date for example Sep 7, 2018 to the total consultation on the date which was 1 week before the specific date i.e., Aug 31, 2018

The growth is calculated by the formula:
(Total consultations for current date - Total consultations for Last weeks date)/(Total consultation for last weekdate)

 

Problem

I can access the current total consultations as it is the current record. But having a hard time trying to access the last week consultations. 

 

What I am looking for is something to let me access the records based on a date condition.

Something that would 

1. take current record date - 7 days,

2. use this date as a filter to apply on whole table,

3, get the records that match this date

4. and sum the total consultation for this records.

 

Now number 2  and 3 are the issue that I am unable to solve. I would apprecitate if anyone can point me in the right direction.

1 REPLY 1
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@habibsyed01,

I make a test using the sample table below. And create the following columns.

Index = RANKX(FILTER(Table3,Table3[Date]<EARLIER(Table3[Date])),Table3[Date],,ASC,Dense)
last 7 days value = CALCULATE(SUM(Table3[Value]),FILTER(Table3,Table3[Index]=EARLIER(Table3[Index])-7))

1.PNG

If the above DAX don't help, please share sample data of your table that can be copied and pasted here. Also post expected result in the forum.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)