Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
How do I get the latest record for the Appointment_ID. For e.g., in this situation, I should only see the last record based on the latest insert date time.
Basically something like: for an appointment ID, show me the row for latest insert date.
Thanks in advance,
RK
Solved! Go to Solution.
Hi @bathbath ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) We can create a measure.
Flag =
var _lasttime=CALCULATE(MAX('Table'[edwlnsert_DateTime]),FILTER(ALL('Table'),'Table'[Appoint_ID]=MAX('Table'[Appoint_ID])))
return IF(MAX('Table'[edwlnsert_DateTime])=_lasttime,1,0)
(3) Place measure [Flag]= 1 on the screening of visual objects.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @bathbath ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) We can create a measure.
Flag =
var _lasttime=CALCULATE(MAX('Table'[edwlnsert_DateTime]),FILTER(ALL('Table'),'Table'[Appoint_ID]=MAX('Table'[Appoint_ID])))
return IF(MAX('Table'[edwlnsert_DateTime])=_lasttime,1,0)
(3) Place measure [Flag]= 1 on the screening of visual objects.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Please see the video below to achieve this using DAX.
Get another column value based on the Max Date or Max Value in PowerBI | MiTutorials - YouTube
You can use a subquery to get the latest record for each Appointment_ID based on the insert date time. Here’s an example of how you can do this:
SQL
SELECT t.Appointment_ID, t.insert_date_time, t.other_columns
FROM your_table t
INNER JOIN (
SELECT Appointment_ID, MAX(insert_date_time) AS latest_date
FROM your_table
GROUP BY Appointment_ID
) subq
ON t.Appointment_ID = subq.Appointment_ID AND t.insert_date_time = subq.latest_date
In this example, the subquery selects the maximum insert date time for each Appointment_ID and groups the results by Appointment_ID. The main query then joins the subquery with the original table on both the Appointment_ID and the insert date time to get the latest record for each Appointment_ID.
I hope this helps! Let me know if you have any further questions. 😊
Thanks Alef for the quick reply but I want to do it via a Power Query or with help of DAX as I don't have access to the SQL piece - The data is coming via dataflow.
Thanks!
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
105 | |
99 | |
98 | |
38 | |
37 |
User | Count |
---|---|
154 | |
120 | |
73 | |
73 | |
63 |