How to replace crosstab cell's value with a string - crosstab

I have column fact, it can carry some difference values:
- Positive values - real values, need to be outputted as is
- 0 is null, output as is
- -1 - special value. Need to ouput "VAC" string in cell.
- -2 - special value. Need to output "SICK" string in cell.
I tried to do it with editing dimension, i replace it with:
case
when [BaseEmp].[FACT_VALUE] = -1 then 'VAC'
when [BaseEmp].[FACT_VALUE] = -2 then 'SICK'
else to_char([BaseEmp].[FACT_VALUE])
end
But now I see error: ORA-01722 invalid number (i think, because strings cannot be aggregated). In column properties I select "min" as aggregate function.
How to replace my special values with strings?

You don't need to change value to VAC, SICK etc.
You need to change DISPLAYED value.
Unlock the padlock in RS.
Select text in your cell
Set text source to "Report Expression"
Write expression like
CASE
WHEN cellValue() = -1 THEN 'VAC'
WHEN cellValue() = -2 THEN 'SICK'
WHEN cellValue() = 0 THEN ''
ELSE cellValue()
END

I tried thinking of a work around regarding your problem. I'm not really sure what you crosstab looks like but considering your parameters above, try creating a data item which holds your case condition for your fact.
Ex.
case
when [BaseEmp].[FACT_VALUE] = -1 then 'VAC' <--- this will produce Any Error Characters
when [BaseEmp].[FACT_VALUE] = -2 then to_char([BaseEmp].[FACT_VALUE]/0) <--- this will produce Missing Value Characters
else to_char([BaseEmp].[FACT_VALUE]) <---- as is
end
Then set the data item's Data Format to number and set the values for the properties as follows:
Kindly give this a try and hopefully it can somehow resolve you problem. Cheers!

Nikita Kuhta checkout Alexey's Baturin's answer. I think it's the appropriate approach. Just one thing if you unlock and select the text in the cell, all of the cell values will be selected and affected by the report expression. You might have several columns or other fact items in the crosstab. If that's the case, what you can do is
Unlock the Report.
Select the crosstab cell/intersection you want to change.
Set the Define Content to Yes.
Drag a Layout Calculation in the crosstab cell/intersection, then insert your case statement.
Thanks to a friend who told be about the define contents. :D

Related

MS Word mail merge: MERGESEQ and MOD

Field codes:
Data:
Expected result:
Actual result:
I was thinking about where I should tweak the codes to fix the issue that the first column of each has three records as other columns do.
Also, a new class name (i.e. 1A, 1B) should be added to the second sheets (i.e. the second and fourth pages).
Thanks in advance for any help!
You need something more like this:
There were two problems - a change of class causes a page break, so at that point you can't rely on on the { =mod({ MERGESEQ },3) } = 0 to show you the right place to break next. Because a column break can also cause a page break, you also have to keep count of the columns to ensure that you can insert the class name every time you have a new page.
An advantage of doing it this way is that you can easily change the number of columns and rows per page.
(I have put one other thing in there, because strictly speaking you need to initialize Class1 when you start the merge).

Set column default value in Google Sheets

I have a finance tracking worksheet that has a number of formulas for each row. What I'd like to add is have these formulas replicate whenever a new row is inserted (fill it with a "default value").
Sheet before adding the row:
Sheet after adding the row:
I'd like some of these cells (B28 in this case) to contain a formula. for this row the formula is:
=IF(ISBLANK(C27), "", CONCATENATE(YEAR(C27), "-", MONTH(C27)))
You might want to consider an ArrayFormula. Here's a place for getting detail. In your case, the big trick is knowing that you can run the formula through all of Column C using the notation something like C1:C. Doing it this way is far more self documenting than burying it in a Google function and it's way more general.
Because the formula is the same for all rows, I added a function that just does the following:
function addRow() {
SpreadsheetApp.getActiveSheet().getRange('B7:B').setValue('=IF(ISBLANK(C7), "", CONCATENATE(YEAR(C7), "-", MONTH(C7)))');
}
I set this function to run on a trigger whenever the sheet is edited. The row numbers increment themselves so not problem there either.
Used this SO question for help: Default cell values when Inserting new row in Google Sheets
delete everything in your B column and paste this into B1 cell:
={"Date", ARRAYFORMULA(IF(C2:C<>"", YEAR(C2:C)&"-"&MONTH(C2:C)))}

Set a text field to 2 values

I'm trying to set a text field to 2 different values
value1 *new line*
value 2
This is my current solution
set(handles.text1,'String',a);
set(handles.text1,'String',Fs);
It the textfield as Fs, completely ignoring a. How can I get it to post both values? Thank you
You can use this to format a text field to have 2 values as you have described. set(handles.text1,'String',sprintf('%-s\n%-s',a,Fs))

Updating the selected dropbox item in a GUI

Currently I have a GUI in which once a 'Submit' button is pressed the drop menu which is left blank is then populated by a calculated value determined by the three other values.
I have successfully figured out how to grab all of the values using this logic:
temp=get(handles.FSTOPpopmenu,{'String','Value'});
fstop=temp{1}{temp{2}};
if (strcmp(fstop,'Select'))
fstop = 0;
else
fstop = str2num(fstop);
end
I just have two questions about this that I can not seem to find an answer for.
How would I go about updating the 'empty' drop menu to the calculated variable (the calculated variable will already be one of the possible values in the predetermined list)?
How would I go about presenting an error, say if I have an if statement checking that the amount of zeros in the array? Would a pop up box be sufficient?
Cheers.
As for your first question matlab's set command is what you're looking for. The documentation is here. You would probably need:
MyValueIndex = find(DropDownValues==NewValue);
switch handleToChange
case handles.handle1
set(handles.handle1,'Value',MyValueIndex);
case handles.handle2
set(handles.handle2,'Value',MyValueIndex);
otherwise
error('Uh oh!');
end
Note that MyValueIndex is the index of dropdown box values that you want. Which is found with a find command on the actual value.
Question two is more of an opinion question but I think that a pop-up box describing the problem is sufficient. Maybe add in a system beep for good measure!
Reference:
http://www.mathworks.com/matlabcentral/answers/22734-resetting-a-pop-up-menu-in-a-gui
http://www.mathworks.com/help/matlab/ref/find.html
http://www.mathworks.com/help/matlab/ref/switch.html
For a popupmenu uicontrol the Value property determines which element of the String property is currently being displayed. Get the String; compare its contents to the calculated variable to get the index; then set that index as the Value property. If the calculated variable is not currently in the String then add it to the String and then set the Value. (Note when comparing you need to compare numbers to numbers or string to strings, so you may need to do an appropriate data type conversion first).
Use an errordlg.

How to design textbox visibility expression in SSRS?

I have an RDL with a table/textbox visibility set to:
=iif(Fields!question_caption.Value = "OBJECTIVE 1",false,true)
I am trying to make this textbox display the value named "narrative" only if the question_caption record = "OBJECTIVE 1". How can I do this? Currently this textbox displays nothing with the above logic. I have the narrative field stored in a Placeholder if that makes any difference.
Here is some sample data for you:
create table #dummy_data
(
question_caption varchar(max),
narrative varchar(max)
)
insert #dummy_data values('1st week dates','week 1'),('2nd week dates','week 2'),('3rd week dates','week 3'),('OBJECTIVE 1','obj 1'),
('5th week dates','week 5')
select * from #dummy_data
I don't see anything wrong with your visibility expression. However, in your question, you're discussing two separate things as one (i.e., visibility & displaying a value in a placeholder).
The hidden property will show an object (tablix, textbox, image, chart, container, etc) if the expression returns false and will hide an object when the expression returns true. When I say hide, I mean that it will remove the object from the grid and, if all is setup properly, the surrounding objects will be shifted to fill the now empty space of the hidden object.
To display (or not) a value is an entirely different thing. To show or hide a value, you would put the following expression in the value property of the placeholder:
=IIF(Fields!question_caption.Value = "OBJECTIVE 1",Fields!narrative.Value,"")
Notice that I've set it up such that if the desired value of the question_caption field is present, it will display the value of the narrative field. Otherwise, it will return an empty string. This will maintain the layout of the report but simply display the desired value or an empty string, based on some criteria.
As for the issues you're current experiencing, I'm not sure why that would be happening. I would first check that you don't have a typo in the Objective 1 hardcoded value in your expression.
If this doesn't help, please comment and let me know some more information about your problem and I'll do my best to help.