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.
Hi everyone!
I reuploaded this post because the previous one was marked as a spam for some reason (for which I hope I'm not doing something wrong).
I am new to DAX and I am struggling to create a formula for a report of mine. I have the model shown below.
Some more details. Each Query has 10 (or so) Event IDs where every Event ID has one Event Count and Event Time. Also each Query runs multiple times and have a unigue SessionUID. So Each many Sessions -> many occurences of each Query -> many occurences of each Event ID for each Query.
What I want to do is:
1) For each Event ID of each Query get the average Event time of one day.
2) Do the same thing but for the previous day (which I can get from 'Run Info'[Previous Date])
3) Calculate the difference Previous Date Average - Current Date Average
4) Somehow store those differences and count all the negative results
5) Show that count on a visual that filters by the Current Date
Here are samples of inputs (sorry for the redacted information but you know...):
And this is some form of the result that I want. For each date on the left, get a count of all the negative (or positive) values that were calculated as described above
.
I hope I made sense in what I want to do. If you have any questions do not hesitate to ask.
Thank you!
Solved! Go to Solution.
@Anonymous ,
Create a calculate column:
Average Time =
CALCULATE (
AVERAGE ( Table[Event Time] ),
ALLEXCEPT ( Table, Table[Query], Table[Event ID], Table[Date] )
)
To achieve the previous date, you need to create an index column in query editor:
Previous Date =
VAR Current_Index = Table[Index]
VAR Previous_Index = Current_Index - 1
RETURN
CALCULATE (
MAX ( Table[Date] ),
FILTER ( Table, Table[Date] = Previous_Index )
)
Achieve the difference:
Difference =
VAR Previous_Date = Table[Previous Date]
RETURN
[Average Time]
- CALCULATE (
AVERAGE ( Table[Event Time] ),
FILTER (
ALLEXCEPT ( Table, Table[Query], Table[Event ID] ),
Table[Date] = Previous_Date
)
)
Finally count the negetive difference:
Count Num =
CALCULATE ( COUNTROWS ( Table ), FILTER ( Table, Table[Differnce] < 0 ) )
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous ,
Create a calculate column:
Average Time =
CALCULATE (
AVERAGE ( Table[Event Time] ),
ALLEXCEPT ( Table, Table[Query], Table[Event ID], Table[Date] )
)
To achieve the previous date, you need to create an index column in query editor:
Previous Date =
VAR Current_Index = Table[Index]
VAR Previous_Index = Current_Index - 1
RETURN
CALCULATE (
MAX ( Table[Date] ),
FILTER ( Table, Table[Date] = Previous_Index )
)
Achieve the difference:
Difference =
VAR Previous_Date = Table[Previous Date]
RETURN
[Average Time]
- CALCULATE (
AVERAGE ( Table[Event Time] ),
FILTER (
ALLEXCEPT ( Table, Table[Query], Table[Event ID] ),
Table[Date] = Previous_Date
)
)
Finally count the negetive difference:
Count Num =
CALCULATE ( COUNTROWS ( Table ), FILTER ( Table, Table[Differnce] < 0 ) )
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 |
---|---|
112 | |
100 | |
76 | |
74 | |
49 |
User | Count |
---|---|
145 | |
108 | |
107 | |
89 | |
61 |