Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #381: Average Monthly Sales with a Twist

PhilipMannering
16 - Nebula
16 - Nebula

Solution attached. Nice work @BS_THE_ANALYST !

 

Spoiler
from ayx import Alteryx
df = Alteryx.read('#1')

df = df.melt(id_vars=['Employee ID', 'Employee Name'])
df.value = df.value.astype(int)


#################################
# Create a running total of value
df['running_total'] = df.groupby('Employee ID').cumsum()


#################################
# Filter running total to be greater than 0
df = df[df.running_total > 0]


#################################
# Take the first three per employee and average
df.groupby('Employee ID').sample(3)\
    .groupby(['Employee ID', 'Employee Name']).value.mean()\
    .round(2).reset_index()

 

BenWo
6 - Meteoroid
Spoiler
Screenshot_Alteryx_Challenge_381.png
Ali_Fawwaz
6 - Meteoroid
Spoiler
Screenshot 2023-07-27 112626.png

MilindG
12 - Quasar

Solution attached

Powerhouse_21
9 - Comet
Spoiler
PH21_381.png

DaisukeTsuchiya
13 - Pulsar
Spoiler
スクリーンショット 2023-07-28 103606.jpg

andrewgu
Alteryx
Alteryx
 

Solution Attached: Designer CloudScreenshot 2023-07-28 115632.jpg

NabilahLoti
8 - Asteroid

Sample solution

Spoiler
AlteryxGui_XMMjkInBgk.png
Yoshiro_Fujimori
15 - Aurora

My solution.

Spoiler
Workflow
Challenge381_1.png
Multi-Row Formula expression
  IF [Row-1:ConsecutiveNo] = 0 AND [Value] = 0
  THEN 0
  ELSE [Row-1:ConsecutiveNo] + 1
  ENDIF
bdoni001
8 - Asteroid

Here is my solution to the challenge.

 

Best regards,
Bona

 

Spoiler
Challenge-381.PNG