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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Compare Daily values for Entity and agency

Hi everyone,

 

I'm facing an issue in term of performance, I have a custom connector which returns a rating for agencies, country and type of rate (Short tem, long term,....)
It returns 7000 lines every day, but I'm facing an issue, this is a sample of my dataset

AgencyNatureEntityDate (DD/MM/YYYY)Rating
FitchLTPoland01/01/20248
FitchLTFrance01/01/20244
FitchLTGermany01/01/20247
FitchSTPoland01/01/20246
FitchSTFrance01/01/20244
FitchSTGermany01/01/20247
FitchLTPoland01/01/20248
FitchLTFrance01/01/20244
FitchLTGermany01/01/20246
FitchSTPoland01/01/20246
FitchSTFrance01/01/20244
FitchSTGermany01/01/20247

 

What I need, to achieve, is to compare the rate for a date and the day before
So to do that, I used the following approach
1. Create a column which is combinaison of Agency, Nature & entity
2. Sort the table by Combinaison & Date
3. Add to index one from 0 and one from 1

4. Make a self join between index0 and Index1

 

After that, I tret the issue with dax or some basic command in Power Query

 

Do you know how can I improve the performance of this case? because a refresh on Power BI services took 1h30 when it did not fail....

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Anonymous 

Instead of doing this in M, I would use  a DAX measure. You can use PREVIOUSDAY() to access the value the previous day.

Value Previous Day = 
CALCULATE ( SUM ( 'Table'[Rating] ), PREVIOUSDAY ( 'Table'[Date] ) )

danextian_0-1742387013780.png

Note: I am not sure what aggregation to use (SUM, MAX, AVERAGE). Your sample data has multiple rows for the same Agency, Nature, Entity and Date combinations.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

3 REPLIES 3
danextian
Super User
Super User

Hi @Anonymous 

Instead of doing this in M, I would use  a DAX measure. You can use PREVIOUSDAY() to access the value the previous day.

Value Previous Day = 
CALCULATE ( SUM ( 'Table'[Rating] ), PREVIOUSDAY ( 'Table'[Date] ) )

danextian_0-1742387013780.png

Note: I am not sure what aggregation to use (SUM, MAX, AVERAGE). Your sample data has multiple rows for the same Agency, Nature, Entity and Date combinations.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
rajendraongole1
Super User
Super User

Hi @Anonymous -Your current approach (creating combination keys, sorting, indexing, and self-joining) is functional but not optimal for large datasets. The long refresh time in Power BI Service is likely due to inefficient data processing, especially in Power Query (M language). Use Power Query Self-Join Method for Maximum Performance. if you can share table or reference will check.

if duplicates exist, clean up.Avoids Indexing & Sorting (which are costly operations).Efficient Merge using a date-based self-join.Power Query handles joins faster than DAX in large datasets.

 

Hope the above suggestion helps.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Anonymous
Not applicable

So my second approach, was to create a unique identifier:
By converting date in int and having for example:
KeyDate

FLT_FRANCE45778 (01/05/2025 convert into int)
Then I create KeyDatePrevious (so on the same line, I will have:
FLT_FRANCE45777 (30/04/2025 convert into int)

 

Then I make a self join on KeyDate and KeyDatePrevious

 

Will this approach get better results ?
I made a test but just with close and apply, and I did not see a significatif enhancement

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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