Forum

New field - change ...
 
Notifications
Clear all

New field - change type/include in calculation

5 Posts
3 Users
0 Reactions
115 Views
(@baxbax)
Posts: 125
Estimable Member
Topic starter
 

Hi,

I have created a query that picks up source data for the period from Feb 2019 to July 2020. Part of the query is to un-pivot the data so that the months appeared as columns. Doing this creates column fields with a null value. I then selected the month columns and replaced the null values with zero. This also changed the type to decimal numbers. I then added a field that summed up the Feb 2019 to July 2020 fields.

I have now updated the source data to include August 2020. How do I update the query so that it automatically includes August, replaces the null values with zero, changes the field type to decimal numbers and includes it in the calculated field so that it sums up Jan 2019 to August 2020?

Thanks

 

Bax

 
Posted : 03/09/2020 10:13 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Bax,

Please supply your workbook so we don't have to recreate the data and query.

Phil

 
Posted : 03/09/2020 6:06 pm
(@baxbax)
Posts: 125
Estimable Member
Topic starter
 

Hi,

Please find the workbook attached. The query is returned in the table in the Sales_Data sheet. The source data is in the Sales sheet.

I created the report initially to look at the periods form Jan 2020 to July 2020. I then added August 2020 data. If you look at the Sales_Data sheet you can see that column Q has returned the numbers for 01/08/20. However in the query there is a step "Replaced Value". This step is to replace any null values in the month columns with zero. If you look at this step in the query you can see that it only picks up the months Jan to July. Similarly in the step "Inserted Sum" I want to sum up all of the months from Jan to August but again it only includes up to July. 

What I want to find out is how to I get these steps to pick up any new months added or is there an alternative method to do what I need?

Thanks

 

BaxInserted_sum.jpgReplaced_value.jpg

 
Posted : 04/09/2020 10:39 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Bax,

In the attached file you can see I created a dynamic list of the columns called 'ColsToAverage' and used that to create the Average column using this code:

= Table.AddColumn(#"Replaced Value", "Average", each List.Average(Record.ToList(Record.SelectFields(_, ColsToAverage))), type number)

I hope that helps.

Mynda

 
Posted : 06/09/2020 2:28 am
(@baxbax)
Posts: 125
Estimable Member
Topic starter
 

Hi Mynda,

Thanks the dynamic list has resolved my issue. I have not used this functionality before. I will have a play Confused

Thanks again

 

Bax

 
Posted : 08/09/2020 5:47 am
Share: