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.
I have some data with missing values and I need to use the other values to fill them in. It if for oil sampling on a mine site. The people taking the oil samples from the equipment (Unit Number) have missed entering some sites they sampled from, so I am guessing the sites based on what was filled out for the other dates.
I would like the rules to be, if the sample site is missing, look for the nearest date for that unit number where the sample was filled out and use that site. If there are two nearest dates, i.e. there was one the day before and one the day after, use site from the latter one.
I already have a macro which does this, but I would like to do it in Power Query. Does anyone know how I can go about this? Attached is the Excel file with the macro.
Solved! Go to Solution.
Then you will have to do add a custom column referring to the unit number above. My video here shows how to reference a previous line. https://youtu.be/xN2IRXQ2CvI
Hi @justlogmein ,
From my understanding, do you want to group by Unit Number and fill down?
Here's my solution.
1.Group by Unit Number, select All Rows in the opreation.
2.Add a custom column to fill down.
3.Remove the unneeded column and expand the Custom column.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @justlogmein ,
From my understanding, do you want to group by Unit Number and fill down?
Here's my solution.
1.Group by Unit Number, select All Rows in the opreation.
2.Add a custom column to fill down.
3.Remove the unneeded column and expand the Custom column.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Your rule says - if there are two nearest dates, i.e. there was one the day before and one the day after, use site from the latter one.
Now taking Sample 19 as an example which is for date 1/02/2021....One day prior reading is 5 and one day latter reading is 1. But as per your rule, the latter one needs to be chosen. Hence, it should be filled in with 1 not 5.
But macro doesn't follow this rule. Macro is filling in this with prior date only not latter date.
However, macro is following the first rule i.e. if the sample site is missing, look for the nearest date for that unit number where the sample was filled out and use that site.
The simplest approach is to fill the value above, down. Make sure the blanks are nulls and not blanks. They should say "null". If they don't say null, select the column and do a replace values and replace an empty string "" with nothing (leave it empty). Then fill down.
It has to be specific to the Unit Number though, and sometimes there are many missing values in a row and it is more accurate to use the site from the closest date, rather than the last date.
Then you will have to do add a custom column referring to the unit number above. My video here shows how to reference a previous line. https://youtu.be/xN2IRXQ2CvI
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.