Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

I want to insert few empty rows based on my date columns.

akumar2609
8 - Asteroid

I need help in below 2 query

              a) inserting the few blank rows in my data set based on the date run field.

              b) I want to take out the difference of the total amount based on the date range.

 

Below are sample data and my requirement:-

 

Data set

CategoryRun timeProduct Total
A20-Nov10
B20-Nov20
C20-Nov-30
D20-Nov40
F21-Nov-20
G21-Nov40
H21-Nov60
I21-Nov30
J21-Nov62
A22-Nov-10
B22-Nov-20
D22-Nov-45
F23-Nov20
C23-Nov45
G23-Nov90
H23-Nov22

 

I have the above data set where I have data for four days i.e. 20, 21, 22 and 23 Nov. 

 

Expected Result

CategoryRun timeTotal
A20-Nov10
B20-Nov20
C20-Nov-30
D20-Nov40
   
Total 40
   
   
CategoryRun timeTotal
F21-Nov-20
G21-Nov40
H21-Nov60
I21-Nov30
J21-Nov62
   
Total 172
Net Balance132
   
   
CategoryRun timeTotal
A22-Nov-10
B22-Nov-20
D22-Nov-45
   
Total -75
Net Balance97
   
   
CategoryRun timeTotal
F23-Nov20
C23-Nov45
G23-Nov90
H23-Nov22
   
Total 177
Net Balance102

 

I need the result in above format where:-

         a) there are few rows gap between all the data set based on the date run

         b) there should be a total column which will add the Product total

         c) there should be a net balance column which is current day total - previous day Net Balance

              for example:- (i) for 20th Nov data run, it should be just the total as it is the first date of the data set

                                    (ii) for 21st Nov data run, Net balance = 172 (21st data total) - 40 (20th Nov day total) = 132,

                                    (iii) for 22nd Nov data run, Net balance = -75 (22nd data total) - 132 (21st Nov day total)= 57 and so on.

 

3 REPLIES 3
Hammad_Rashid
11 - Bolide

Here’s how you can achieve your requirements in Alteryx:

a) To insert blank rows based on the date run field, you can use the Multi-Row Formula tool. 

  • Select the Multi-Row Formula tool from the tool palette and connect it to your input data.
  • In the Multi-Row Formula configuration window, select the Run time field as the Grouping Field.
  • In the Expression field, enter the following formula: IF FIRST() THEN [Product Total] ELSEIF LAST() THEN [Product Total] ELSEIF NOT ISNULL([Product Total]) THEN [Product Total] ELSEIF ISNULL([Product Total]) THEN "" ENDIF, where Product Total is the field that you want to insert blank rows for.
  • Rename the output field to something like Data with Blank Rows.
  • Run the workflow to see the output.

b) To take out the difference of the total amount based on the date range, you can use the Summarize tool. 

  • Select the Summarize tool from the tool palette and connect it to your input data.
  • In the Summarize configuration window, select the Run time field as the Group By field.
  • In the Summarize configuration window, select the Product Total field and choose Sum as the Aggregate function.
  • Add a new field by clicking the Add Field button and enter the following formula: IF FIRST() THEN [Product Total] ELSEIF NOT FIRST() THEN [Product Total] - PREVIOUS([Product Total]) ENDIF, where Product Total is the field that you want to calculate the difference for.
  • Rename the output fields to something like Total and Net Balance.
  • Run the workflow to see the output.
akumar2609
8 - Asteroid

Thanks for the quick reply...would you mind sharing the workflow with me?

akumar2609
8 - Asteroid

Can you please share the workflow as I am not able to replicate in the alteryx whatever you suggested.

Labels
Top Solution Authors