-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQN 1 - 10
501 lines (473 loc) · 16.4 KB
/
QN 1 - 10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
-------------------------------------
-- Measure: [# Wins Most Tournaments]
-------------------------------------
MEASURE 'Key Measures'[# Wins Most Tournaments] = MAXX(VALUES('Teams'[Team Name]), [# Tournaments])
DisplayFolder = "Day 1 Won most Tournaments"
FormatString = "0"
--------------------------------------
-- Measure: [Won the most Tournaments]
--------------------------------------
MEASURE 'Key Measures'[Won the most Tournaments] =
// won most tournaments
//# Tournaments = COUNTROWS(Tournaments)
//# Wins Most Tournaments = MAXX(VALUES('Teams'[Team Name]), [# Tournaments])
CALCULATE (
SELECTEDVALUE(Teams[Team Name] ),
TOPN ( 1, ALL ( Teams ), [# Wins Most Tournaments], DESC )
)
DisplayFolder = "Day 1 Won most Tournaments"
-----------------------
-- Measure: [Q1 Curbal]
-----------------------
MEASURE 'Key Measures'[Q1 Curbal] =
VAR CountWinners =
SUMMARIZE(
'Tournaments',
'Tournaments'[Winner],
"count winners", COUNT( 'Tournaments'[Winner] )
) -- count the winnders on tournament table
VAR TopWinner = TOPN( 1, CountWinners, [count winners] ) -- use topn to find max
RETURN
CALCULATE(
SELECTEDVALUE( 'Tournaments'[Winner] ),
TopWinner
) -- choose the winner that matches the value
DisplayFolder = "Day 1 Won most Tournaments"
-------------------------------------
-- Measure: [Host Countries that won]
-------------------------------------
MEASURE 'Key Measures'[Host Countries that won] =
VAR ResultTable =
SUMMARIZECOLUMNS(
Tournaments[Host Won],
Tournaments[Host Country],
Tournaments[Key Id],
KEEPFILTERS( TREATAS( {1}, Tournaments[Host Won] )),
"No Tournaments", [# Tournaments]
)
VAR Countries =
CONCATENATEX(ResultTable, Tournaments[Host Country], ", ", Tournaments[Host Country], ASC)
RETURN
Countries
DisplayFolder = "Day 2 Host Countries that won"
-----------------------
-- Measure: [Q2 Curbal]
-----------------------
MEASURE 'Key Measures'[Q2 Curbal] =
CONCATENATEX(
TOPN(
1,
SUMMARIZE(
'Tournaments',
'Tournaments'[Host Country],
"host won", SUM( 'Tournaments'[Host Won] )
),
[host won]
),
'Tournaments'[Host Country],
", ",
'Tournaments'[Host Country], ASC
)
DisplayFolder = "Day 2 Host Countries that won"
-----------------------------------------
-- Measure: [Periods between Tournaments]
-----------------------------------------
MEASURE 'Key Measures'[Periods between Tournaments] =
VAR FirstYear =
CALCULATE(
MIN( 'Tournaments'[Year] ),
ALL( 'Tournaments' )
)
VAR _CurrentYear = SELECTEDVALUE( 'Tournaments'[Year] )
VAR _PreviousYear =
CALCULATE(
MAX( 'Tournaments'[Year] ),
FILTER(
ALLSELECTED( 'Tournaments' ),
'Tournaments'[Year] < _CurrentYear
)
)
VAR Result =
IF(
_CurrentYear = FirstYear,
BLANK( ),
_CurrentYear - _PreviousYear
)
RETURN
Result
DisplayFolder = "Day 3 Longest gap in years between tournaments"
FormatString = "0"
------------------------------------------------
-- Measure: [Longest Period between Tournaments]
------------------------------------------------
MEASURE 'Key Measures'[Longest Period between Tournaments] =
CONVERT(
MAXX( 'Tournaments', [Periods between Tournaments] ),
STRING
)
& " Years"
DisplayFolder = "Day 3 Longest gap in years between tournaments"
-----------------------
-- Measure: [Q3 Curbal]
-----------------------
MEASURE 'Key Measures'[Q3 Curbal] =
MAXX(
ADDCOLUMNS(
'Tournaments',
"Gap Years",
VAR currentYear = 'Tournaments'[Year]
VAR prevYear =
CALCULATE(
MIN( 'Tournaments'[Year] ), -- for each row find the min tournament year where the year is greater than the current year
FILTER( 'Tournaments', 'Tournaments'[Year] > currentYear )
)
VAR Result =
IF(
prevYear = BLANK( ),
BLANK( ),
prevYear - 'Tournaments'[Year]
)
RETURN
Result
),
[Gap Years]
)
& " years"
DisplayFolder = "Day 3 Longest gap in years between tournaments"
------------------------------------
-- Measure: [Hosts most Tournaments]
------------------------------------
MEASURE 'Key Measures'[Hosts most Tournaments] =
CONCATENATEX(
TOPN(
1,
SUMMARIZECOLUMNS(
'Tournaments'[Host Country],
"Tournaments Hosted", [# Tournaments]
),
[# Tournaments], DESC
),
'Tournaments'[Host Country],
", ",
'Tournaments'[Host Country], ASC
)
DisplayFolder = "Day 4 Highest Number of hosted tournaments"
-----------------------
-- Measure: [Q4 Curbal]
-----------------------
MEASURE 'Key Measures'[Q4 Curbal] =
CONCATENATEX(
TOPN(
1,
SUMMARIZE(
'Tournaments',
'Tournaments'[Host Country],
"Hosted", COUNT( 'Tournaments'[Host Country] )
),
[Hosted], DESC
),
'Tournaments'[Host Country],
", ",
'Tournaments'[Host Country]
)
DisplayFolder = "Day 4 Highest Number of hosted tournaments"
---------------------------------------
-- Measure: [# Number of Second Places]
---------------------------------------
MEASURE 'Key Measures'[# Number of Second Places] = CALCULATE([# Tournament Standings], 'Tournament Standings'[Position] = "2")
DisplayFolder = "Day 5 Country with most second place finishes"
FormatString = "0"
-------------------------------------
-- Measure: [Most 2nd Place finishes]
-------------------------------------
MEASURE 'Key Measures'[Most 2nd Place finishes] =
CONCATENATEX(
TOPN(1,
SUMMARIZECOLUMNS('Teams'[Team Name],
"Tournaments Second", [# Number of Second Places]),
[# Number of Second Places],
DESC),
'Teams'[Team Name],
", ",
'Teams'[Team Name], ASC)
DisplayFolder = "Day 5 Country with most second place finishes"
-----------------------
-- Measure: [Q5 Curbal]
-----------------------
MEASURE 'Key Measures'[Q5 Curbal] =
CONCATENATEX(
TOPN(
1,
FILTER(
SUMMARIZE(
'Tournament Standings',
'Tournament Standings'[Team Name],
'Tournament Standings'[Position],
"Number of 2nds", COUNT( 'Tournament Standings'[Position] )
),
'Tournament Standings'[Position] = "2"
),
[# Number of Second Places]
),
'Tournament Standings'[Team Name],
", ",
'Tournament Standings'[Team Name], ASC
)
DisplayFolder = "Day 5 Country with most second place finishes"
--------------------------------
-- Measure: [# Team Appearances]
--------------------------------
MEASURE 'Key Measures'[# Team Appearances] = COUNTROWS('Team Appearances')
DisplayFolder = "Day 6 Country with most appearances"
FormatString = "0"
-----------------------------------
-- Measure: [Most Team Appearances]
-----------------------------------
MEASURE 'Key Measures'[Most Team Appearances] =
CONCATENATEX(
TOPN(1,
SUMMARIZECOLUMNS('Teams'[Team Name],
"Most Appearances", [# Team Appearances]),
[# Team Appearances],
DESC),
'Teams'[Team Name],
", ",
'Teams'[Team Name], ASC)
DisplayFolder = "Day 6 Country with most appearances"
---------------------------
-- Measure: [Q6 Curbal way]
---------------------------
MEASURE 'Key Measures'[Q6 Curbal way] =
CONCATENATEX(
TOPN(
1,
SUMMARIZECOLUMNS(
'Teams'[Team Name],
"Most Appearances", COUNT( 'Team Appearances'[Key Id] )
),
[Most Appearances], DESC
),
'Teams'[Team Name],
", ",
'Teams'[Team Name], ASC
)
DisplayFolder = "Day 6 Country with most appearances"
------------------------------------------------------
-- Measure: [# Tournament Standings 1st and 2nd place]
------------------------------------------------------
MEASURE 'Key Measures'[# Tournament Standings 1st and 2nd place] = CALCULATE([# Tournament Standings], 'Tournament Standings'[Position] IN {"1","2"})
DisplayFolder = "Day 7 Most finishes in top two"
FormatString = "0"
----------------------------------------
-- Measure: [Most 1st and 2nd Positions]
----------------------------------------
MEASURE 'Key Measures'[Most 1st and 2nd Positions] =
CONCATENATEX(
TOPN(1,
SUMMARIZECOLUMNS('Teams'[Team Name],
"Most 1st and 2nd", [# Tournament Standings 1st and 2nd place]),
[# Tournament Standings 1st and 2nd place],
DESC),
'Teams'[Team Name],
", ",
'Teams'[Team Name], ASC)
DisplayFolder = "Day 7 Most finishes in top two"
---------------------------
-- Measure: [Q7 Curbal way]
---------------------------
MEASURE 'Key Measures'[Q7 Curbal way] =
CONCATENATEX(
TOPN(
1,
FILTER(
SUMMARIZE(
'Tournament Standings',
'Tournament Standings'[Team Name],
'Tournament Standings'[Position],
"Count Position", COUNT( 'Tournament Standings'[Position] )
),
'Tournament Standings'[Position] IN { "1", "2" }
),
[Count Position]
),
'Tournament Standings'[Team Name],
", ",
'Tournament Standings'[Team Name], ASC
)
DisplayFolder = "Day 7 Most finishes in top two"
-----------------------------------------
-- Measure: [Longest Period between Wins]
-----------------------------------------
MEASURE 'Key Measures'[Longest Period between Wins] =
VAR PrevWin =
CALCULATE(
MAX( 'Tournament Standings'[PreviousWin] ),
'Tournament Standings'[Position] = "1"
)
VAR Result =
IF(
ISBLANK( PrevWin ),
BLANK( ),
CONVERT( PrevWin, STRING ) & " Years"
)
RETURN
Result
DisplayFolder = "Day 8 Longest Period between Wins"
-------------------------
-- Measure: [Q8 Jen copy]
-------------------------
MEASURE 'Key Measures'[Q8 Jen copy] =
MAXX(
ADDCOLUMNS(
'Tournaments',
"Gap in Wins",
VAR CurrYr = 'Tournaments'[Year]
VAR CurrWinner = 'Tournaments'[Winner]
VAR PrevYr =
CALCULATE(
MIN( 'Tournaments'[Year] ),
FILTER(
'Tournaments',
'Tournaments'[Year] > CurrYr
&& 'Tournaments'[Winner] = CurrWinner
)
)
RETURN
IF(
PrevYr = BLANK( ),
BLANK( ),
PrevYr - 'Tournaments'[Year]
)
),
[Gap in Wins]
)
& " years"
DisplayFolder = "Day 8 Longest Period between Wins"
------------------------------------------
-- Measure: [Shortest Period between Wins]
------------------------------------------
MEASURE 'Key Measures'[Shortest Period between Wins] =
VAR PrevWin =
CALCULATE(
MIN( 'Tournament Standings'[PreviousWin] ),
'Tournament Standings'[Position] = "1"
)
VAR Result = IF( ISBLANK( PrevWin ), BLANK( ), PrevWin )
RETURN
Result
DisplayFolder = "Day 9 Most Consecutive Wins"
-----------------------------------
-- Measure: [Most Consecutive Wins]
-----------------------------------
MEASURE 'Key Measures'[Most Consecutive Wins] =
CONCATENATEX(
TOPN(
1,
SUMMARIZECOLUMNS(
'Teams'[Team Name],
"MostConsecutiveWins", [Shortest Period between Wins]
),
[Shortest Period between Wins], ASC
),
'Teams'[Team Name],
", ",
'Teams'[Team Name], ASC
)
DisplayFolder = "Day 9 Most Consecutive Wins"
-------------------------
-- Measure: [Q9 Jen copy]
-------------------------
MEASURE 'Key Measures'[Q9 Jen copy] =
MINX(
ADDCOLUMNS(
'Tournaments',
"Gap in Wins",
VAR CurrYr = 'Tournaments'[Year] --current year for row context
VAR CurrWinner = 'Tournaments'[Winner] -- current winner for row context
VAR PrevYr =
CALCULATE(
MIN( 'Tournaments'[Year] ), -- min year
FILTER(
'Tournaments',
'Tournaments'[Year] > CurrYr
&& 'Tournaments'[Winner] = CurrWinner
)
) -- iterate through each row to show the first year which is greater than current row year and is the same tournament winner
RETURN
IF(
PrevYr = BLANK( ),
BLANK( ),
PrevYr - 'Tournaments'[Year]
)
),
[Gap in Wins]
)
& " years"
DisplayFolder = "Day 9 Most Consecutive Wins"
------------------------------------------
-- Measure: [Finals played but never lost]
------------------------------------------
MEASURE 'Key Measures'[Finals played but never lost] = IF([# Tournament Standings 2nd place] = 0, [# Tournament Standings 1st place])
DisplayFolder = "Day 10 Most finals played but never lost"
FormatString = "0"
----------------------------------------------
-- Measure: [# Tournament Standings 1st place]
----------------------------------------------
MEASURE 'Key Measures'[# Tournament Standings 1st place] = CALCULATE([# Tournament Standings], 'Tournament Standings'[Position] IN {"1"})
DisplayFolder = "Day 10 Most finals played but never lost"
FormatString = "0"
----------------------------------------------
-- Measure: [# Tournament Standings 2nd place]
----------------------------------------------
MEASURE 'Key Measures'[# Tournament Standings 2nd place] = CALCULATE([# Tournament Standings], 'Tournament Standings'[Position] IN {"2"})
DisplayFolder = "Day 10 Most finals played but never lost"
FormatString = "0"
-----------------------------------------------
-- Measure: [Most Finals played but never lost]
-----------------------------------------------
MEASURE 'Key Measures'[Most Finals played but never lost] =
CONCATENATEX(
TOPN(
1,
SUMMARIZECOLUMNS(
'Teams'[Team Name],
"MostFinals played but never lost", [Finals played but never lost]
),
[Finals played but never lost], DESC
),
'Teams'[Team Name],
", ",
'Teams'[Team Name], ASC
)
DisplayFolder = "Day 10 Most finals played but never lost"
----------------------------------------------------
-- Measure: [Most Finals played but never lost copy]
----------------------------------------------------
MEASURE 'Key Measures'[Most Finals played but never lost copy] =
VAR FirstPosition =
CALCULATE(
[# Tournament Standings],
'Tournament Standings'[Position] IN { "1" }
)
VAR SECPosition =
CALCULATE(
[# Tournament Standings],
'Tournament Standings'[Position] IN { "2" }
)
VAR FinalsPlayedNotLost =
IF( SECPosition = 0, 0, FirstPosition )
RETURN
CONCATENATEX(
TOPN(
1,
SUMMARIZECOLUMNS(
'Teams'[Team Name],
"MostFinals played but never lost", FinalsPlayedNotLost
),
FinalsPlayedNotLost, DESC
),
'Teams'[Team Name],
", ",
'Teams'[Team Name], ASC
)
DisplayFolder = "Day 10 Most finals played but never lost"