Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi Team,
I have the door table
Here I want to find that whether door is being open continuously(having open status & not closed) for more than 1 hour for each DeviceId.
Data Description:
The Status column shows whether door is open or Closed.
CreatedOn column shows time duration.
DeviceId column shows Deviceid.
My first requirement is:
We need to add the minutes(createdon) between each row for same deviceid where the status = open. But where a status = closed (if closed comes in between open) we reset the number of minutes.
So we sum by the previous value where status = Open -
Something like If current status = open and previous status = open then sum the time and do the below:
Sum(previous value + new sum)
Where/if status = closed set time count = 0
Sum(previous value + new sum) is going to take into account only the consecutive open status >60 min for same divice id
whenever status is closed, this Sum(previous value + new sum) will be reset to/equal to 0
So on the first open status, the count will be 0. Then the next open status it will be time between 2 open statuses, then on the third it will be the time between two open statuses add the previous time.but any close status then time is reset.
For example of above description:
The brown color highlight does not alert because it did not complete 60 min as Closed came up.
Could you please help me with a power query logic/dax logic?
Second Requirement:
This is only a sample data. But we have billions of rows of data in our dataflow that comes from SQL views.
@marcorusso sir came with a brilliant idea of below:
'The suggestion is not to use DAX for this calculation. You can precalculate the maximum open state duration by preprocessing your data (SQL, Power Query, Spark, anything else...). Using DAX does not make much sense because performance will quickly decrease when you try to compute the same calculation in every report through a measure.
So can you help me prepare data upfront. we need to solve the problem with a with a proper data model. for example, create a table with the longest open events upfront (in whatever technique you are comfortable with)'.
Could you please help me to achieve this?
PFA file here B&M.pbix
Please let me know if you need further info!
Thanks in advance!
@marcorusso @tharunkumarRTK @Greg_Deckler @Ahmedx @Anonymous @Anonymous
Solved! Go to Solution.
I wrote the logic as per my understanding.
Here is the link to download the file:
Table Name: "Door Power Query"
Hope it helps
Need a Power BI Consultation? Hire me on Upwork
Connect on LinkedIn
|
I wrote the logic as per my understanding.
Here is the link to download the file:
Table Name: "Door Power Query"
Hope it helps
Need a Power BI Consultation? Hire me on Upwork
Connect on LinkedIn
|
Hi Tharun,
This is an amazing solution and wonderfully crafted!🤩
You are truly a masterpiece and i still can't believe that this issue got resolved.
You came like a saviour for this community!
I will mark it as solution
Many thanks!
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |