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.
Hello everyone!
I am having trouble in creating a specific logic.
The ideia is find the average of the diference of the days between specific rows.
For example:
IDDateCriteria
1 | 18/01/2018 | First |
2 | 25/01/2018 | First |
3 | 21/01/2018 | First |
4 | 01/02/2018 | First |
1 | 03/02/2018 | Second |
2 | 14/03/2018 | Second |
1 | 05/02/2018 | Third |
In this example, I want to know the date difference between criteria but in the same ID.
The formula is = DateDifference ID = Second - First
In excel that would be:
ID 1 = 03/02/2018-18/01/2018 = 16 days
ID 2 = 14/03/2018-25/01/2018 = 48 days
ID 3 = Blank (there is no second criteria)
ID 4 = Blank (there is no second criteria)
So, the average of that is 32.
Just like the table under:
DateDIFF (Second - First) | |
ID 1 | 16,00 |
ID 2 | 48,00 |
ID 3 | Blank |
ID 4 | Blank |
Average | 32,00 |
I want to do the same for (Third-Second), and so on...
How Can I create a Measure of that?
Thanks ikn advance, I am stuck in this problem for a few days now....
PS: I want create that in DAX not in Power Query.
Solved! Go to Solution.
Hi @GertRiet
You may try to create measures as below:
Diff = VAR a = CALCULATE ( MAX ( Table1[Date] ), FILTER ( ALL ( Table1 ), Table1[Date] < MAX ( Table1[Date] ) && Table1[ID] = MAX ( Table1[ID] ) ) ) RETURN DATEDIFF ( a, MAX ( Table1[Date] ), DAY )
Average = AVERAGEX (Table1, [Diff] )
Regards,
Cherie
Hi @GertRiet
You may try to create measures as below:
Diff = VAR a = CALCULATE ( MAX ( Table1[Date] ), FILTER ( ALL ( Table1 ), Table1[Date] < MAX ( Table1[Date] ) && Table1[ID] = MAX ( Table1[ID] ) ) ) RETURN DATEDIFF ( a, MAX ( Table1[Date] ), DAY )
Average = AVERAGEX (Table1, [Diff] )
Regards,
Cherie
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 |
---|---|
109 | |
95 | |
77 | |
65 | |
53 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |