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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Kyle_Escosia
Frequent Visitor

Growth Rate % Change

I'm working on a data visualization on STOCK MARKET TRADES and I need to calculate the Average Growth Rate of the Stock daily.


But the catch is, that they don't always deal everyday. They only do Monday-Friday. I can't seem to find a workaround for this.

Logic is simple but I'm having trouble with it in Power BI

Data is like this:

Capture.PNG

2day = CALCULATE(AVERAGE('sample'[price]))
yesterday1 = CALCULATE(
    [2day], 
    DATEADD('sample'[DATE],-1,DAY),
    ALL('sample'[DATE].[Day]),
    ALL(' sample'[Day Name])
)


Any help will do. Thanks!

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi, @Kyle_Escosia

Whether there is no Saturday and Sunday in your date.

If so, you could try this way:

Add an index column by date column.

Then try this formula to create a measure:

yesterday2 = 
CALCULATE (
    [2day],
    FILTER ( ALL ( 'sample' ), MAX ( 'sample'[Index] ) - 1 = 'sample'[Index] )
)

If you want use other fields in  slicer, you could use ALLEXCEPT instead of ALL.

for example:

FILTER ( ALLEXCEPT ( 'sample' , 'sample'[Code] ), MAX ( 'sample'[Index] ) - 1 = 'sample'[Index] )

Result:

10.JPG

 

Best Regards,

Lin

 

 

Community Support Team _ Lin
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
v-lili6-msft
Community Support
Community Support

hi, @Kyle_Escosia

Whether there is no Saturday and Sunday in your date.

If so, you could try this way:

Add an index column by date column.

Then try this formula to create a measure:

yesterday2 = 
CALCULATE (
    [2day],
    FILTER ( ALL ( 'sample' ), MAX ( 'sample'[Index] ) - 1 = 'sample'[Index] )
)

If you want use other fields in  slicer, you could use ALLEXCEPT instead of ALL.

for example:

FILTER ( ALLEXCEPT ( 'sample' , 'sample'[Code] ), MAX ( 'sample'[Index] ) - 1 = 'sample'[Index] )

Result:

10.JPG

 

Best Regards,

Lin

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

 

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Super User
Super User

You might be able to do this with an IF statement checking for "Monday" and if so doing a -3 instead of a -1. Or, you might try a variation on my Sequential Quick Measure:

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Sequential/m-p/380231

 


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.