The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I have a table with the fields: Name Date Type Time Index and Times
The index column has this formula: =CONTAR.SI($A$2:A2,A2)
The times column has this formula: =IF(A3=A2,D3-D2,"")
Those 2 columns are additional to my table
What I want is to load my original table in power pivot and from there add the 2 columns and with dax formulas
Take out the index and get the difference between times.
To later be able to verify how long a user was inside and how long he was outside.
I need to know for each day, how long the user was inside and how long outside, for that I need the time difference.
In excel it is easy to achieve since the formula is manipulated, but I have not been able to do it in dax.
Could someone help me please?
Solved! Go to Solution.
Hi @MaritoDominguez ,
You could create two calculated columns as follows.
Index = COUNTROWS(FILTER('Table',[Hora]<=EARLIER('Table'[Hora])&&[Nombre]=EARLIER('Table'[Nombre])))
Diff = var _pre=CALCULATE(MAX('Table'[Hora]),FILTER('Table',[Index]<EARLIER('Table'[Index])&&[Nombre]=EARLIER('Table'[Nombre])))
return IF(ISBLANK(_pre),BLANK(),[Hora]-_pre)
You can download the attachment for more details.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @MaritoDominguez ,
You could create two calculated columns as follows.
Index = COUNTROWS(FILTER('Table',[Hora]<=EARLIER('Table'[Hora])&&[Nombre]=EARLIER('Table'[Nombre])))
Diff = var _pre=CALCULATE(MAX('Table'[Hora]),FILTER('Table',[Index]<EARLIER('Table'[Index])&&[Nombre]=EARLIER('Table'[Nombre])))
return IF(ISBLANK(_pre),BLANK(),[Hora]-_pre)
You can download the attachment for more details.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
76 | |
65 | |
52 | |
51 |
User | Count |
---|---|
128 | |
117 | |
78 | |
65 | |
63 |