I have an SSRS report that has a column in it that when exported to Excel (XLSX) displays properly, but when exported to CSV, it gives an error that I can't seem to figure out how to fix.
The column value is the following expression (sorry for the formatting, SSRS makes it difficult to format this into an easily readable statement):
=IIF(IsNothing(Fields!SomeField1.Value) Or Fields!SomeField1.Value = "",
"",
(Replace("- " + Fields!SomeField1.Value,
",",
vbCrLf + "-")))
+ IIF(IsNothing(Fields!SomeField2.Value) Or Fields!SomeField2.Value = "",
"",
vbCrLf + "- " + Fields!SomeField2.Value)
The error displayed in the CSV file is:
The value in the CSV's formula bar shows =- N/A. The - seems to be what causes the error but I can't figure out why. This behavior is especially strange because there are other rows with values in the same column like - Test comment and - Yet another testing comment that display without any errors...
The - character is required because the business wants the column to display as a bulleted list. Is there any way to fix this without removing the -?
You can prefix the cell value with an apostrophe (the ' character) to tell Excel that the value you are entering into the cell is to be treated as text rather than a formula and should be displayed as-is.
Sorry don't have rep to comment but you can just add an extra IIF statement around your code block using Globals!RenderFormat = "CSV" to add formatting to the expression for that field. It shouldn't require an extra function (unless this is required for more than just the one field)
Related
I'm currently trying to record a macro for my excel spreadsheet, but keep recieving the message "The specified formula cannot be entered because it uses more levels of nesting than are allowed in the current file format can anyone help me out in fixing the formula to make it smaller?
=IF(ISNUMBER(SEARCH("Conductor + Surface",B3)),"Conductor + Surface",IF(OR(ISNUMBER(SEARCH("17
1/2",B3)),ISNUMBER(SEARCH("Drilling",B3)),ISNUMBER(SEARCH("12 1/4",B3)),ISNUMBER(SEARCH("8
1/2",B3)),ISNUMBER(SEARCH("Run Screens",B3)),ISNUMBER(SEARCH("Temporay",B3)),ISNUMBER(SEARCH("BOP
Hop",B3)),(ISNUMBER(SEARCH("Data Acquisition",B3)))),"Inter, Res, Lower Comp., &
TP&A",IF(ISNUMBER(SEARCH("Maintenance",B3)),"BOP Maintenance",IF(OR(ISNUMBER(SEARCH("Re-
entry",B3)),ISNUMBER(SEARCH("Wellbore Prep",B3)),ISNUMBER(SEARCH("Run
Completion",B3)),ISNUMBER(SEARCH("Install TH",B3)),ISNUMBER(SEARCH("BOP
Pull",B3)),ISNUMBER(SEARCH("Subsea Move Off",B3)),ISNUMBER(SEARCH("BOP Run -
Completion",B3))),"Upper Comp & TH",IF(ISNUMBER(SEARCH("Rig Move - N and C",B3)),"Rig Move - N and
C",IF(ISNUMBER(SEARCH("Install XMT",B3)),"Install XMT w/ Rig",IF(ISNUMBER(SEARCH("Open
Plugs",B3)),"Open Plugs",IF(ISNUMBER(SEARCH("Rig Move - S and B",B3)),"Rig Move - S and
B",IF(ISNUMBER(SEARCH("Install VXT",B3)),"Install VXT","ERROR IN EXCEL FORMULA")))))))))
Currently there is a column with tasks that are too in depth, aka "New Conductor + Surface" or "ADCO - DG2 8 1/2" I want to make a new column with shorter names for each of them depending on certain words that are in the detailed column. I would then like to return an error if there is a detailed task that is not described properly.
This can be done by modifying the setup in this link to a 2 column lookup table.
See below for sample:
Array formula is =IFERROR(INDEX(lookupList,MATCH(TRUE,ISNUMBER(SEARCH(list,D7)),0),2),"NOT FOUND")
remember to press Ctrl+Shift+Enter when exiting cell edit mode.
I want to get data from a column in excel sheet. In my case it's the 3rd one. I use a for loop in order to scan all the cells and I have the following column :
1,724.87
1,560.00
18,109.61
64.37
4,898.22
1,784.47
43,430.30
When I use the WorkSheet.Cells.Item($x,3).Text function in the loop to get the content of each cell, I get the following :
1,724.87
1,560.00
#######
64.37
4,898.22
1,784.47
#######
The ####### can be seen in the .xls file when I open it in excel. When I expand the width of the column it shows the actual number again. So I assume that it reads it as it is. What can be done in order to get the actual number?
It seems that the issue with WorkSheet.Cells.Item($x,3).Text is that .Text will represent anything shown on the screen in the cell. In my case is #######
To show the actual value of the cell ,should be using WorkSheet.Cells.Item($x,3).Value2. More difference between .Value, .Value2 and .Text can be found in this post :
What is the difference between .text, .value, and .value2?
Very new to PQ, and I'm pretty sure it can do what I need in this situation, but I need help figuring out how to get there.
I have a timesheet report with 20 columns covering 50 rows that will need to be formatted to a word doc for uploading into a separate system. The original data in the cells range from 0 to any negative 2 digit number (ex: "-20"), but they need to be formatted to a seven-character set ending in ".00".
Examples:
0 will need to become "0000.00"
-4 will need to become "-004.00"
-25 will need to become "-025.00"
I think I should be able to use the text.insert function, but I'm not familiar enough with M Language to get it to do what I want it to do.
Any solutions/suggestions?
Here's my previous answer revisited...set up to use a function. You can just invoke the function once for each column you want to reformat. You'll just pass the name of the column you want to reformat to the function as you invoke the function each time.
Create a new blank query:
Open the new query in Advanced Editor and highlight everything in it:
Paste this over the highlighted text in the Advanced Editor:
let
FormatIt = (SourceColumn) =>
let
Base = Number.Round(SourceColumn,2)*.01,
Source = try Text.Start(Text.Range(
if Base < 7 then Text.From(Base) & "001" else
Text.From(Base),0,7),2) & Text.Range(Text.Range(
if Base < 7 then Text.From(Base) & "001" else
Text.From(Base),0,7),3,2) & "." & Text.End(Text.Range(
if Base < 7 then Text.From(Base) & "001" else
Text.From(Base),0,7),2)
otherwise "0000.00"
in
Source
in
FormatIt
...and click Done.
You'll see a new function has been created and listed in the Queries list on the left side of the screen.
Then go to your query with the columns you want to reformat (click on the name of your query that has the numbers you want to change in it, on the left side of the screen) and...
Click Invoke Custom Function
And fill out the pop-up like this:
- You can make up a different New column name than Custom.1.
- Function Query is the name of your query you are calling (the one you just created when you pasted the code)...for me, it's called Query1.
- Source Column is the column with the numbers you want to format.
...and click OK.
You can invoke this function once for each column. It will create a new formatted column for each.
You can use this formula = Text.PadStart(Text.From([Column1]),4,"0")&".00") in PQ to add new column that looks similar to your needs.
Here's an admittedly "busy" formula to do it:
= Table.AddColumn(#"Changed Type", "Custom", each Text.Start(Text.Range(if Number.Round([Column1],2)*.01 < 7 then Text.From(Number.Round([Column1],2)*.01) & "001" else Text.From(Number.Round([Column1],2)*.01),0,7),2) & Text.Range(Text.Range(if Number.Round([Column1],2)*.01 < 7 then Text.From(Number.Round([Column1],2)*.01) & "001" else Text.From(Number.Round([Column1],2)*.01),0,7),3,2) & "." & Text.End(Text.Range(if Number.Round([Column1],2)*.01 < 7 then Text.From(Number.Round([Column1],2)*.01) & "001" else Text.From(Number.Round([Column1],2)*.01),0,7),2))
It assumes your numbers that you want formatted are in Column1 to start. It creates a new column...Custom...with the formatted result.
To try it out, start with Column1 already populated and loaded into Power Query; then click the Add Column tab and then the Custom Column button, and populate the pop-up window like this:
...and click OK.
With more time, the repetitive parts could be made with variables to shorten this up a bit. This could also be turned into a function, given some time. But I don't have the time right now, so I figured I'd give you at least "something."
I'm debugging some ColdFusion code (although the question is really language-agnostic), and from the debug output, have two columns of text.
Those columns are field name <tab> value and want to be able to quickly convert this into test code.
The text I start off with:
a 1
b 2
c 3
etc
The code I want to end up with:
structInsert(myStruct, "a", 1);
structInsert(myStruct, "b", 2);
structInsert(myStruct, "c", 3);
etc
Ordinarily, I'd use Excel, pasting the two columns of data into columns A and B, and create a formula in column C that concatenates A and B something like
="structInsert(myStruct, """ & A1 & """, " & B1 & ");"
This works fine (and is one of the main reasons I love Excel).
But I'm wondering... given that the whole world doesn't have Excel, how does everyone else do this?
Thanks!
Well I like to do with Notepad++ or Eclipse with search and replace feature with regular expression.
Like search for
([a-z]*)\t(\d)
replace with
structInsert(myStruct,"\1",\2);
So simple.. right?
You could do this with regular expressions.
In CFEclipse/CFBuilder open the Find/Replace dialogue
Find: ^(.+?)\t(.+?)$
Replace with: structInsert(myStruct, "$1", $2);
Check Regular Expressions
Click Replace All
if I load a csv file into excel, value 123.320000 will become 123.32.
i need to view all contents as they are. any way to stop excel from hiding trailing zeros?
reading other posts, i found that doing something like this could work "=""123.3200000" but that would mean running regex on the file every time i want to view it.. since it comes in xxxx|###|xxx format and i have no control over the generation part.
How exactly are you loading the CSV file?
If you import it as "Text" format then Excel will retain all formatting, including leading/trailing zeros.
In Excel 2010 you import from the "Data" tab and choose "From Text", find your CSV file then when prompted choose to format the data as "Text"
I'm assuming that once the imported values are in the sheet, you want to treat them as numbers and not as text, i.e. you want to be able to sum, multiply, etc. Loading the values as text will prevent you from doing this -- until you convert the values back to numbers, in which case you will lose the trailing zeros, which brings you back to your initial conundrum.
Keeping in mind that there is no difference between the values 123.32 and 123.3200000, what you want is just to change the display format such that the full precision of your value is shown explicitly. You could do this in VBA like so:
strMyValue = "123.3200000"
strFormat = "#."
' Append a 0 to the format string for each figure after the decimal point.
For i = 1 To Len(strMyValue) - InStr(strMyValue, ".")
strFormat = strFormat & "0"
Next i
With Range("A1")
.Value = CDbl(strMyValue)
.NumberFormat = strFormat
'Value now shown with same precision as in strMyValue.
End With