The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I am currently working on stock market data in Power BI and need to create a DAX measure that identifies when a stock’s price approximately matches a given value on previous days. For example, if the price of XYZ shares is 120, I want to find out when the price of XYZ shares was approximately 120 on previous days.
Solved! Go to Solution.
Thanks for the reply from Rakesh1705 and SachinNandanwar , please allow me to provide another insight:
Hi, @MAP
Can you tell me if your problem is solved? If yes, please accept their as solution.
Regarding the issue you raised, my solution is as follows:
1.First I have created the following table and the column names and data are the data you have given:
2.First, you can try using the following calculation table, using its id column as a slicer:
Table 2 = SELECTCOLUMNS('Table','Table'[ID],'Table'[date])
3.Second, use the following measures and modify the filters:
MEASURE =
VAR nday =
MAX ( 'Table 2'[Table_date] )
VAR nprice =
MAXX (
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[date] = nday ),
'Table'[price]
)
VAR selce11 =
MAX ( 'Table 2'[Table_ID] )
RETURN
IF (
ISFILTERED ( 'Table 2'[Table_ID] ),
IF (
ABS ( MAX ( 'Table'[price] ) - nprice ) < 1
&& MAX ( 'Table'[ID] ) = selce11,
1,
0
),
1
)
4.Here's my final result, which I hope meets your requirements.
Please find the attached pbix relevant to the case.
Of course, if you have any new ideas, you are welcome to contact us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Since I dont have your sample data and your idea of approximate price, I have implemented my idea here.
I have taken all the historical data of tata motors from Yahoo finance.
Source Data
First the closing price is rounded off
Now latest price is found
Starting digit of latest price is found
Number of digits in the latest price is found
Nearest Lowest round figure is found
Nearest highest round figure is found
Required date indicators is found
Filtered the "Price Indicator" text in the final column
I hope you have your answer. If my answer is satisfying with your criteria then please accept the same as your solution.
Thank you for replying. I'll see if your answer fulfills what I want.
Thanks for the reply from Rakesh1705 and SachinNandanwar , please allow me to provide another insight:
Hi, @MAP
Can you tell me if your problem is solved? If yes, please accept their as solution.
Regarding the issue you raised, my solution is as follows:
1.First I have created the following table and the column names and data are the data you have given:
2.First, you can try using the following calculation table, using its id column as a slicer:
Table 2 = SELECTCOLUMNS('Table','Table'[ID],'Table'[date])
3.Second, use the following measures and modify the filters:
MEASURE =
VAR nday =
MAX ( 'Table 2'[Table_date] )
VAR nprice =
MAXX (
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[date] = nday ),
'Table'[price]
)
VAR selce11 =
MAX ( 'Table 2'[Table_ID] )
RETURN
IF (
ISFILTERED ( 'Table 2'[Table_ID] ),
IF (
ABS ( MAX ( 'Table'[price] ) - nprice ) < 1
&& MAX ( 'Table'[ID] ) = selce11,
1,
0
),
1
)
4.Here's my final result, which I hope meets your requirements.
Please find the attached pbix relevant to the case.
Of course, if you have any new ideas, you are welcome to contact us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If price is 120 then 120.01 to 120.99 will be consider close
User | Count |
---|---|
25 | |
12 | |
8 | |
8 | |
7 |
User | Count |
---|---|
27 | |
12 | |
12 | |
12 | |
6 |