May 28, 2021
I need to preserve a value in a cell based on the results of a conditional statement. Here is an outline of the problem.
I have a source table with a text column of 'check' values for the conditional validation. In the same table is a column of numeric values to be placed in the target cell in the target table. The goal is to overwrite or initially load the target cell if the AND is TRUE. However, if it is not true I get the existing value set to 0 which is not what I need. I am trying to keep history across status types. The file shows it more clearly. So here is the run down:
Base Data:
Status Days in Status
'Ready' 11
Target table:
Column for Status 'Ready'
Value of Days in Status 11
If condition for loading to Value of Days in Status in target table:
=IF(AND(Data!E8="Ready",Data!I8>0),Data!I8,<<<<What can go here to preserve the existing cell value?>>>>)
Presently there is a value of '0' in the FALSE condition so that the IF will work for demonstration purposes.
VIP
Trusted Members
December 7, 2016
Hello,
In your sample file you write that in cell E5 you want the number three if the condition is false, but where does this three come from? Is it based on a calculation or is it just a fixed number?
As shown in your sample file, I can’t figure out what the problem is, if you want number three to be shown, put in that number.
I also recommend you to not have the TODAY() function in every row of your table, as the data grows you risk to get longer loading/updating time. Put it instead in a single cell outside the table.
Br,
Anders
May 28, 2021
Anders,
Thanks for the response. Here is the flow of data for E5 and all other cells in the tblStoryTracking table.
Day One: The Status say for the Data cell Data!E8 = "Ready" that gets us to the needed column. ID 'aa' is the 'link' if you will between Data and tblStoryTracking. At that point the value of Data!I8, a 3, should be placed in the E5 cell.
Day Two: Data!E8 is now "Design", the project has moved on to the next stage. The ID is still 'aa'. The new value in Data!I8 would be a 1 as the project has only been in that status one day and goes into E6. There is no new value for E5, I want E5 to stay 3 has a historical value as the project continues to move forward. I want each cell in row E, and all of the other cells to retain their old values as we move through the phases of the project.
We are tracking the time that the project stays in each phase to determine if there is too much time being spent in a given phase (status). This is then displayed, everyday in a stacked bar chart to give us the cycle trend on each project over time.
Hopes this help provide some clarification.
Additionally:
The use of TODAY is to calculate the time elapsed between the update date and the current day, the table in Data never gets very big, usually no ,ore than 150 rows max. This gives us the values in I8:I30. As these dates, and the subsequent Days value change the appropriate cell in tblStoryTracking, say E5 for example, is updated to the new day value if E8 Status is a match, I.E. from 1 to 2 to 3 etc. with the final value needing to be preserved as discussed above.
It is messy but necessary as this is a KPI for the projects.
William
VIP
Trusted Members
December 7, 2016
Hello,
I am sorry, but I can't follow your steps with the sample file you have attached.
For example, in sheet Data, cell E8, the value is todays date. Cell I8 has no value, it is blank.
The id for row 8 is dd, not aa.
I also don't follow with why you compare the update date against todays date, unless you of course update the date in that column, but then how do you keep track of when the status changes occured?
I suggest you use tabular data setup in your tblRaw, thus adding a new row for each status change, which gives you the possibility to keep track of when the status changed for each ID. Not sure if this is in line with what you want to see, it is however what I think (assume) you want. See attached file for an example.
Br,
Anders
May 28, 2021
Anders,
Apologies for the horrible example, I realize I was looking at another Excel worksheet. So let's start from the beginning so that things might make a bit more sense.
1) A project changes status over time, as you have seen. Analysis to Ready to Design, etc.
2) A project will spend N number of days in a state, form 1 - N.
3) The Update is the date that the project entered the current status.
4) The number of days that the project has been in a given status is Days(Delta)= TODAY - Update date.
5) The desired reporting number is the Days.
6) The needed grouping is project (vertical axis) by Status(horizontal axis).
This data is then used for stacked bar charts and scatter plots to determine where the project is spending the most time so that we can adjust the flow of work.
So lets go back to the original spread sheet explanation and use the correct cell id's. By way of illustration there are two sets of example tables to capture the before/after effect. The process is the same for both sets so the flow examples are valid.
In the attached file here is the hypothetical flow:
Starting with table Sample 1 as the Base table, target example table tblStoryTracking 1
Day One: The Status say for the project 'aa' (Data!Cell B5) is in "Ready" state shown in Data!Cell C5 the calculated Days (Data!G5) is say '11', for the example. In tblStoryTracking 1 table this is what happens: we match Data!B5(Project) to Cell C5 and Data!C5 (Status) to Column "Ready" in the Story Tracking table. We populate Cell E5 with the Calculated Days from Data!G5. In tblStoryTracking 1 we now have '11' in Cell E5.
So now tblStoryTracking 1 looks like this:
ID Analysis Ready Design
aa 0 11 0
Day Two: Say that Status Data!B9 for project 'aa' is now "Design", the project has moved on to the next stage. The ID is still 'aa' but we now have a new Days value in Data!G9, '1'. This new value (Data!G9, Days) is loaded to the tblStoryTracking 2 table we follow roughly the same process we match Data!B9(Project) to Cell C9 and Data!C9 (Status) to Column "Design" in the Story Tracking table. We populate Cell F9 with the Calculated Days, '1', from Data!G9.
Now here is the issue:
Continuing with table Sample 2 (Data) and the base table and target example table tblStoryTracking 2
When the project changed status from "Ready" to "Design" the value in Cell E9 was changed to '0'. And the 'Design" Cell F9 changed to '1', as shown below:
So now tblStoryTracking 2 looks like this:
ID Analysis Ready Design
aa 0 0 1
I need to keep the '11' located in Cell E5(E9) for historical tracking purposes. This is the issue, how do I keep that value in Cell E5(E9) from being flipped to '0' because the value in Data!C9 is no longer "Ready" but has change to "Design"(Data!C9,in Sample 1). I have tried all sorts of twists and turns using IF/AND/OR/NOT/IFS and no solution as yet. Each cell in tblStoryTracking 1/2 is an IF/AND statement as you can see when you select one of the cells.
I hope that this explains the situation better.
William
VIP
Trusted Members
December 7, 2016
Hello,
Thanks for the new sample file. Just wondering, did you check the modified sample file I uploaded in my previous post? I am asking because with that approach you can get what you want, just modify it so you check against todays date. If you want to only have one row per ID and only have one status and update column then you need to involve VBA to do the days calculations and write the value to correct cell in tblStoryTracking.
With a table where you add a new row for each status change you then keep track of when the status changed and can look it up and do needed calculations.
Br,
Anders
May 28, 2021
Anders,
Yes I did review the workbook you sent. Our issue with that method is that our data comes from a tool and we have only a single entry per project with current status and the last project update date. So we are stuck with the data organization you see in the first worksheet. I have a feeling that this will indeed call for a VBA script. If nothing else for the sake of sanity as I have tried a host of IF's in various forms, learned a lot about IF's and limitations so it has not been a complete waste.
I will need to get some tutorials on VBA syntax and structure so I can do this. I have not coded in almost 20 years so this should be very interesting :-).
Thanks for all you help with this,, it is appreciated.
William
May 28, 2021
Anders.
Figured it out. It was actually simple, horribly so, with the following IF in the target cell.
B14 contains: =IF(Data!$E16="Analysis", IF(Data!$I16>B14,Data!I16,),B14) all that was needed was to place the 'B14' as the false action on the Status check. This IF is far simpler than the one I started with as well. Still have some glitches with fighting a circular reference, underlined in the example as well, it but that is for another thread.
Thanks again.
William
1 Guest(s)