Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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:
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!
Solved! Go to Solution.
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:
Best Regards,
Lin
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:
Best Regards,
Lin
Hi,
Share the link from where i can download your PBI file.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
116 | |
102 | |
78 | |
77 | |
49 |
User | Count |
---|---|
145 | |
108 | |
107 | |
89 | |
61 |