I'm looking for a way to default a cell value with data validation applied, but allow the user to overwrite the value to one of the valid values allowed.
I have a demo spreadsheet here.
And visually:
I have data validation on column D that provides a list of possible markup percentages from column G, however, I want a default value in there so I have written a formula to work this out (based on there being a value in an adjacent cost cell).
I enter the item, I enter a cost and the markup defaults. All good.
But, when I click the dropdown I don't get any values popup. the formula is shown instead.
I have tried conditional formatting based on making the cell text and background white, but this is sub-optimal for my real world (significantly more complex) scenario.
How can I achieve what I am after - a default value of 50% if there is a cost value, but selectable from the drop-down.
The only way to add a "default" value based on a condition is to use on edit (simple or installable) script.
Example:
The following is an simple on edit trigger. If a cell from column C below the first row is edited, then the cell to the right will be 50% (assuming that the cell format is set to display %)
function onEdit(e){
if(e.range.columnStart === 3 && e.range.rowStart > 1){
e.range.offset(0,1).setValue(0.5);
}
}
Resources
https://developers.google.com/apps-script/guides/sheets
https://developers.google.com/apps-script/guides/triggers
Related
I am trying to use Textjoin and IFS within a formula in Google Sheets to return a combination (all, none, or some) of values. I want to values to all be listed in the same cell at the end of a given row. In order for this to work, I am referencing a second tab within the same sheet.
I tried the following formula:
=ARRAYFORMULA(TEXTJOIN(" ",(IFS(Sheet2!F53="D",$F$5,Sheet2!R53="D",$R$5,Sheet2!T53="D",$T$5,""))))
What I want to happen is that if "D" is in the cell referenced on the 2nd sheet, it returns the specified text in the cell corresponding to $F$5, etc. If there are no cells with D in the referenced cell, then I just want it blank. When I used this formula, I get an error saying there is a wrong number of arguments for Textjoin.
I tried this formula:
=ARRAYFORMULA(TEXTJOIN(",", Sheet2!F23="D", $F$5, Sheet2!R23="D", $R$5, Sheet2!T23="D", $T$5, ""))
It simply listed each value in the cell corresponding to $F$5, etc and said true or false following the value. That is obviously not what I want either.
can you try:
=TEXTJOIN(" ",1,{IF(Sheet2!F53="D",$F$5,),IF(Sheet2!R53="D",$R$5,),IF(Sheet2!T53="D",$T$5,)})
I'm trying to show a text field item as a percentage, issue is that there are several queries depending on this item (it refreshes reports based on the value).
Right now I have decimal values in there (1 = 100% , 0.5 = 50% and so on).
But the customer is asking to show this item as a percentage (50% when I have 0.5).
Does anyone know how to achieve this?
PS: The #col_name#% approach doesn't work well for this case.
Thanks
One way to solve this is to have the a 2nd item.
Suppose the base item is P1_COMMISSION and that is the value stored in the database - I suppose that would be a value between 0 and 1. Create another item called P1_COMMISSION_PCT which is displays the percent value. If this is a form item, this item would not have a database columns as source.
Make P1_COMMISSION hidden
Add a computation after the form initialisation to calculate the P1_COMMISSION_PCT based on P1_COMMISSION
Add a dynamic action on change of P1_COMMISSION_PCT to recalculate the value of P1_COMMISSION
One option is to
set current item to be hidden (so that you wouldn't see 1 or 0.5 as its values, but other objects would still be able to use it) and
create a new, display only item, whose source would be current item, but properly formatted, e.g.
TO_CHAR(TO_NUMBER(:P1_COL_NAME) * 100) || '%'
I'm trying to add some indicators into a matrix to show an increase or decrease from the previous year
This is my design view
And this is how it's viewed in the report
I would obviously like my up and down arrows to appear in the currently empty columns. Also I'm wondering if there is a way of deleting the first empty column after 2014/15 as there is no year to compare it to.
SSRS supports a function called Previous, which will be useful in your scenario. Assuming that the name of your column group is "Fiscal", the difference of two years can be calculated as
=Count(Fields!IDNUMBER.Value) - Previous(Count(Fields!IDNUMBER.Value), "Fiscal")
Because you can't know the range of the numbers in advance, I suggest to use a "numeric" expression like
=Sign(Count(Fields!IDNUMBER.Value) - Previous(Count(Fields!IDNUMBER.Value), "Fiscal"))
for the indicator, so the ranges can be defined by single values -1, 0 and 1:
To hide the first indicator column, right-click the column header in design view and click Column Visibility..., then in the cnfiguration dialog specify to hide based on an expression like
=IsNothing(Previous(Fields!Fiscal.Value, "Fiscal"))
Here's a screenshot of my design view:
I am having some issues with specifying a dynamic cell range for a "data validation".
I'm aware you can do some tricky stuff with = "Projections!M4:M"&O2. You can update the content of cell O2 for example to 3 and the output would be Projections!M4:M3.
This makes the value "dynamic". These tricks don't seem to work in the "Cell Range:" input field in the Data Validation selection/configuration screen.
My problem is, I hate seeing drop down arrows (call me o.c.d) for rows that have no content, my number of rows will grow in the future so I don't have any other option than selecting M4:Mfills the whole 1002 rows with drop down arrows.
Has anyone worked out a trick to make dropdown arrows only show up for rows that are filled?
I'm using = COUNTA(B4:B)to get the number of rows that are filled and = "Projections!M4:M"&O2 to make the desired Projections!M4:MX string but the "Cell Range" input field in the Data validation screen doesn't accept this as valid either.
Well I didn't find a direct solution, but something that I can work with to resolve my issue which was I hate seeing drop down arrows for empty rows.
I turned a filter on for a column that will always be filled in and filtered by conditions Cell is not empty but i'd prefer a better solution.
I'm trying to use the filter() formula within a spreadsheet, from another tab within that spreadsheet.
I've got a number of drop-down menus that, when used, bring up the relevant data from the table I'm filtering from.
I've managed to make it work when it's a table of data from row 2 downwards (row 1 being a header row), but now the table starts from the 6th row down with other information above it (most of it, however, is blank). As such, now all of the options come up automatically when the drop down menus are blank.
I either need the formula below to start from the 6th row down, or to ignore the blank cells. It must be an easy solution but for the life of me, I can't find it anywhere on the internet (I'm pretty new with spreadsheet formulas so please be gentle).
This is the formula I've been using that works when there are no blank rows:
=FILTER(Sheet2!A:T,(Sheet2!D:D=B12)+(Sheet2!F:F=C12)+(Sheet2!G:G=D12)+(Sheet2!H:H=E12)+(Sheet2!I:I=F12)+(Sheet2!N:N=G12)+(Sheet2!O:O=H12)+(Sheet2!T:T=I12))
If it helps, the drop-down options are both numbers and text, and I'm using Google Sheets rather than Excel.
You can probably just change your ranges to 'A6:T' instead of 'A:T'. 'A:A' range syntax gets all rows in that column. 'A6:A' will start it at 6 but not define an ending row, which I think is what you want.
This is your formula with those small changes:
=FILTER(Sheet2!A6:T,(Sheet2!D6:D=B12)+(Sheet2!F6:F=C12)+(Sheet2!G6:G=D12)+(Sheet2!H6:H=E12)+(Sheet2!I6:I=F12)+(Sheet2!N6:N=G12)+(Sheet2!O6:O=H12)+(Sheet2!T6:T=I12))
The =isBlank() formula may be useful to you as well. It takes a cell reference and returns true/false. You can wrap this in NOT() to give the opposite result, i.e =NOT(ISBLANK(A1)) will return true if there is a value.