SSRS: GetReportParameters and date values - reporting-services

I have an RDL file where I enter two dates, run a query based on that date range to populate a drop-down list and then populate another text field with a default value that is based on the Label of the drop-down list's selected item.
The Data Types are Date/Time for the first two dates, Text for the drop-down list and Text for the last text field. The drop-down list's Value as returned by the query is actually a Date/Time but if I set the Data Type to Date/Time then it does not work as expected when I Preview the report (when I select a value in the list the current selection just reverts back to "<Select a Value>" and nothing is put into the last Text field, regardless of its Data Type).
Anyway, with the drop-down list having a Data Type of Text, all works OK in the Preview.
The problem is that I have custom interface for the reports, and try as I might, I cannot get my own implementation to correctly get the default value for my last Text field.
I noticed that SSRS only wants dates in a certain format and so with some manipulation of the dates I can get the ValidValues for the drop-down list parameter by calling GetReportParameters() with the Values parameter set as follows:
values[0].Name = "fromdate";
values[0].Value = "2011-11-01 00:00:00";
values[0].Label = "";
values[1].Name = "todate";
values[1].Value = "2011-11-30 00:00:00";
values[1].Label = "";
parameters = GetReportParameters("myreport", null, true, values, null);
Following this call, parameters[2] now contains ValidValues and I can populate my own drop-down list in the custom UI.
However, when I need to get the default value for the text field, I cannot seem to get the input values in a format that GetReportParameters() will accept:
values[0].Name = "fromdate";
values[0].Value = "2011-11-01 00:00:00";
values[0].Label = "";
values[1].Name = "todate";
values[1].Value = "2011-11-30 00:00:00";
values[1].Label = "";
values[2].Name = "datelist";
values[2].Label = "The date is 22nd Nov 2011";
values[2].Value = "2011-11-22 00:00:00";
parameters = GetReportParameters("myreport", null, true, values, null);
After this call I expect the parameter for my text field to have a DefaultValues value that I can access but it is 'null' the State is set to HasOutstandingDependencies. Why is this? All of the dependencies have been set - correctly as far as I can see, so what might be the issue?
I realise that I may be getting into difficulties with the conversion of Data Type between Date/Time and Text, but if I try to keep it consistent and use Date/Time throughout then I cannot get it to work even in the RDL's Preview, so I'm not sure that's the way to go either!
Thanks in advance.

Related

VLookup not working on full numbered Value

I created a Google Spreadsheet (File Name Product Test) and I have an ID field on column A which contains the word ID plus some letters and numbers (Example "ID-KNYT-12345"). The KNYT part is different per ID, some KNYT some DMXF etc.
So in column B I added a custom formula (Sample below) which processes the ID. If KNYT only numbers are kept. If DMXF the DMXF part is included plus the numbers.
I then have a vlookup/importrange formula on column C which is supposed to use the converted value in column B to lookup the value from another sheet and retrieve a certain information.
The problem is if the converted value contains all numbers like 12345 the vlookup fails, "Did not find value in lookup evaluation". If the converted value contains letters and numbers like DMXF-25452 the lookup works. If I manually type 12345 on column A the lookup works. Why would the lookup say it didn't find a result when the value is there? More details below
I checked, all cells involved are in format Number>"AUTOMATIC".
I checked, the value 12345 is definitely found on the other sheet (Imported Range)
I checked these values online, I found no hidden characters or spaces
The data is from an email with attached Excel file. I don't download the file, I just click to preview it and copy-paste the entire table over to my Product Test spreadsheet
The custom Formula:
function Convert(Thevalue)
{
Thevalue = Thevalue.toString().replace("ID-KNYT-", "");
Thevalue = Thevalue.toString().replace("ID-DMXF-", "DMXF-");
if (Thevalue == "DMXF-2245"){Thevalue = "Evaluated";}
if (Thevalue == "DMXF-3268"){Thevalue = "Pending";}
return Thevalue;
}
The Vlookup (Not actual sheet url just a sample)
VLOOKUP($B1,IMPORTRANGE("https://docs.google.com/spreadsheets/d/feiugsdfjhsdkjfhiesdfjh-p-dsflkjgsdf/edit#gid=000222333","sheet1!$A:$C"),3,FALSE)
UPDATE: This seem to fix it for me. Looks like if the return value is all numbers and no letters it is a NaN issue
if (!isNaN(Thevalue))
{
return Number(Thevalue);
}
else
{
return Thevalue;
}
Your custom function returns text strings. The vlookup() function does not consider the number 123 and the text string "123" equal. To make it work, convert the lookup keys to text with to_text(), like this:
=vlookup( to_text($B1), Sheet1!$A:$C, columns(Sheet1!$A:$C), false )
As RemcoE33 said, the custom function seems superfluous, because the same thing can be done with a plain vanilla spreadsheet formula that employs regexreplace(), like this:
=arrayformula( regexreplace( to_text(A2:A), "ID(?:-KNYT)?-", "" ) )

archiving / copying all the values in column A to column C based on date

archiving / copying all the values in column A to column C based on date. Also, if the date is change, a new set of values will be copied and the previous value won't be deleted.I was working on a daily schedule of every employee at the same time it will be recorded as their attendance based on the date. Can someone help me?
Example 1
Example 2 : if I change the date, the previous record won't get deleted and will copy a new set of values based on date
If I press the (save button) I want all the the values from column B2:B4 will be copied to column F2:F4 based on the date on column C1
The 2nd screenshot shows if I change the date and press again the (save button) the previous value won't get deleted and a new set of values will be copied based on the actual date on column C1
In order to solve your issue I suggest you to use Apps Script and write a script and use this function:
function dateFunction() {
var sheet = SpreadsheetApp.getActiveSheet();
var currDate = sheet.getRange("C1").getValue();
var originRange = sheet.getRange("B2:B4");
var headers = sheet.getDataRange().getValues()[0];
var dateFound = false;
for (var i=5; i<headers.length && !dateFound; i++) {
if (currDate.toString() == headers[i].toString()) {
originRange.copyTo(sheet.getRange(2, i + 1, 3));
dateFound = true;
}
}
if (!dateFound)
SpreadsheetApp.getUi().alert("Date not found!");
}
The script works by gathering all the dates from your headers and will try to see if there's a match with the date from the C1 cell. If a match has been found, the values will be copied correspondingly, otherwise, an alert prompt will show up specifying that the date has not been found.
Now, you will need to link this function to a button so it will only be executed when you click it.
You can easily do that by inserting a drawing and shape/draw it so it will resemble a button of your liking. You will have to Save and Close it.
Then, when you right click on it the option of Assign a script will appear and you have to put the name of the function from above in there, as shown below:
So now, every time you press the Save button, the script will be executed.
Furthermore, I suggest you read the following links since they might help you:
Apps Script Spreadsheet Service;
Sheet Class .getDataRange();
Range Class .copyTo().

API indexedDB- Showing date in format DD.MM.YYYY

I have an html with a form where I colect data type: text, radio and date.
When I pick up the date, I can see the format is dd.mm.yyyy.
Then I went to see the way the date is save and in the BD I see:
Object
date
:
"2017-09-12"
Now my question is, is there a way to show in the html the date in the format dd-mm-YYYY or to save the date in dd-mm-yyyy instead.
Thank you so much in advance
Marcela
You can store date objects in indexedDB. A date object is not concerned with how it is displayed, and does not provide or store properties related to a date's format.
If you are viewing the set of objects in an object store using a browser's devtools panel, date values are displayed according to some built-in setting in devtools. The way dates are displayed in a devtools view of an object store does not reflect how dates are actually stored. Dates are actually stored as simple numbers. There is a big difference between how a value is stored and how it is displayed.
Therefore, so long as you property store dates as dates (not as strings that look like dates), then you can choose how to display a date after retrieving it from indexedDB. You make this decision outside of using indexedDB, because this is not a concern of indexedDB. indexedDB is only concerned with storing values.
So, when writing code:
1) When saving an object with a date property to indexedDB, ensure the date property is of type date.
2) When getting an object from indexedDB, get its date property, and then convert the date property into a string in a format that you prefer.
Here is some really ugly pseudo-code to help you:
// This function accepts a date value as input, and then returns a
// string representing the formatted date
function formatDate(dateValue) {
// Get the parts of the date
var dayOfMonthNumber = dateValue.getDate();
// The +1 is because January is 0, but we want it to be 1
var monthNumber = dateValue.getMonth() + 1;
var yearNumber = dateValue.getYear();
// Compose a string of the parts
var dateString = '';
dateString += dayOfMonthNumber;
dateString += '-';
dateString += monthNumber;
dateString += '-';
dateString += yearNumber;
return dateString;
}
myObject.myDateProperty = new Date('1.2.3');
saveObjectInIndexedDB(myObject);
var myObject = getObjectFromIndexedDB();
var myDatePropertyAsADate = myObject.myDateProperty;
var myFormattedDateString = formatDate(myDatePropertyAsDate);
var myElement = document.getElementById('myElement');
myElement.textContent = myFormattedDateString;

make a table of data in google docs if cells in spreadsheet contain data

I am trying to write a script which creates a table in a google docs file with the results after a user has submitted a form.
In the form the user can enter up to 16 invoices and 16 payments; however on my summary pdf I don't want to display a table full of empty cells if the user has only entered one invoice.
I tried to write an if statement to say "If "invoice number" cell is not empty, then create a table row, if not, do nothing", but it creates the rows anyway even when the cells are empty and I can't quite figure out why.
Anyone have any ideas? Here's the code:
var invoiceData = [['Invoice Number', 'Invoice Amount', 'Due Date of Invoice']];
table1 = copyBody.appendTable(invoiceData);
var tab1row1=table1.appendTableRow();
if (sheet3.getRange("A20").getValue() ==! 0);{
tab1row1.appendTableCell(sheet3.getRange("A3").getValue());
tab1row1.appendTableCell("£" + sheet3.getRange("B3").getValue());
tab1row1.appendTableCell(sheet3.getRange("C3").getValue());
And the same code repeated for rows up to row 16 (but with changed numbers obviuosly).
The cell A20 (which is the one specified within the IF statement) is a cell containing the formula =VALUE(A3).
Thank you in advance.
The not operator, which is an exclamation point, can't be after the equal signs.
function testAfunction() {
Logger.log(1===1); //true
Logger.log(1!==99); //true
Logger.log(1==!99); //false
};
Also, remove the extra semi-colon.
Should be:
if (sheet3.getRange("A20").getValue() !== 0) {

Show or Hide SSRS column based on specific parameter value

I am having trouble showing/hiding a column based on parameter value chosen.
How my report is set up:
Parameter: ImportStatus --ImportStatus parameter has three values you can choose from: M, V, E
If I choose ImportStatus value = 'M', then I want the report to display a specific column.
Currently, if I go to Column Visibility screen of a column I want to show/hide, I am able to hide column for all values instead of specific. Any idea how to do this correctly?
My expression:
=IIF(Parameters!ImportStatus.Value = "M",true,false)
The expression
=IIF(Parameters!ImportStatus.Value = "M",true,false)
will give the same result as
=(Parameters!ImportStatus.Value = "M")
The expression you need to give specifies whether or not to hide the column, so to show a column where #ImportStatus = "M", you would simply reverse the logic:
=Not(Parameters!ImportStatus.Value = "M")