ISBLANK(...) = FALSE even thought the cell is blank in google sheet - arrays

Hi everyone,
I have 2 tables, 3rd column for Table 1 is Value 1 and 3rd column for Table 2 is Value 2. I combined these 2 tables by expanding both tables first so that all the columns are aligned as shown in the screenshot above (Column E to Column H).
The formula in all the yellow cells are:
Cell E4 : =QUERY(A4:C10,"Select A,B,C,' ' label ' ' 'Value 2' ")
Cell E12 : =QUERY(A12:C20,"Select A,B,' ',C label ' ' 'Value 1' ")
Cell K7 : =QUERY({E5:H10;E13:H17},"Select * where Col1 is not null",0)
Cell P7 : =ArrayFormula(IF(ISBLANK(M7:M12),100,M7:M12))
In column P, I want to return 100 as Value 1 if the cells in Column M is blank. So by right I should get 2,34,55,100,100,100 in column P but right now the formula still return 3 blank cells.
I suspect that is because the QUERY function that I used before which make the cell is not blank although it seems like still a blank cell. May I know is there any trick that I can use to find the blank cells in column M and column N (preferably don't touch the QUERY formula) since ISBLANK() is not working in this case?
Any help or advise will be greatly appreciated!
Edited

makes sense. you cant use ISBLANK because cell is not blank. remember that QUERY inserted an empty space.
try:
=ARRAYFORMULA(IF(ISBLANK(TRIM(M7:M12)), 100, M7:M12))
ISBLANK is so sensitive that it will detect even residue from TRIM
update:
=ARRAYFORMULA(IF(TRIM(M7:M12)="", 100, M7:M12))

Related

Finding adjacent column values from the last non-null row of a certain column

Is there a simple in-built function to select adjacent values from the last non-null row for a certain column?
In the below example the last non-null value in Column A is "E", and I'd like to select the corresponding value "13" from the next column.
Try:
=VLOOKUP(INDEX(A:A,MAX((A:A<>"")*(ROW(A:A)))),A1:B,2,0)
Refer Selecting the last value of a column. There are 22 answers toi choose from.
I like =INDEX(I:I;MAX((I:I<>"")*(ROW(I:I)))). It is one of the shortest and it copes with blank rows.
Add VLOOKUP and you can get the value on the adjacent columns.
try:
=QUERY(A3:B, "select B where A !='' offset "&COUNTA(A3:A)-1)
or:
=ARRAYFORMULA(VLOOKUP(INDIRECT("A"&MAX(IF(A2:A="",,ROW(A2:A)))), A2:B, 2, 0))
or:
=ARRAYFORMULA(VLOOKUP(INDEX(QUERY({A2:A, ROW(A2:A)},
"where Col1 !='' order by Col2 desc"), 1, 1), A2:B, 2, 0))
=indirect("B" & max(ARRAYFORMULA(row(A1:A)*if(A1:A="",0,1))),true)
or
=indirect("B" & arrayformula(max(if(A1:A<>"",row(A1:A),0))),true)
or with offset
=offset(B1,ARRAYFORMULA(MAX(if(A:A="",0,row(A:A))))-1,0)

color first five rows of a table in SSRS

Iam developing a report where I need to provide special effects on 1st few columns. How can I color code or provide 3D effect for first five rows of a table in SSRS? Also, count of values in these columns?
For example:
My date count
A 3
B 4
C 1
D 1
E 5
F 6
G 7
Now, I should color rows start from A to E and get total count of that ( e.g. 14 in this case)
How can I I acheive this?
While Strawberryshrub's answer would probably work just fine, there's an easier way that can get you the same result. You should be able to use the SSRS function RowNumber to indicate which rows should be colored. Try the following expression in the background color property for that row.
=IIF(RowNumber(Nothing) < 6, "Green", "No Color")
Also, for the count that you need, you should be able to use a similar pattern.
=SUM(IIF(RowNumber(Nothing) < 6, Fields!count.Value, 0))
One possible option is to cathegorize your first column with an calculated field:
'Name: CustomCathegory
=IIF(Fields!MyDae.Value = "A" Or
Fields!MyDae.Value = "B" Or
Fields!MyDae.Value = "C" Or
Fields!MyDae.Value = "D" Or
Fields!MyDae.Value = "E", "Cathegory1", "CathegoryElse")
Now you can use the row coloring (font or background) and use the following expression:
=IIF(Fields!CustomCathegory = "Cathegory1", "Blue", "Black")
You can also sum by CustomCathegory (textbox outside the detail section)
=Sum(IIF(Fields!CustomCathegory = "Cathegory1", Fields!Count.Value, 0))
or group your table by CustomCathegory and add header or footer with the sum per CustomCathegory

Power BI - How can I visualize percent of rows with a certain value and of those rows, percent with a value above or below a number?

Data
My data looks like this. I want to see a bar chart of the % of rows where column Y/N? contains "Y" and of those rows, the percent that % column contains a value of 7 or above, and the percent where % column contains a value below 7
Something like...
IF [C2:C19] = Y, THEN COUNTIF [B2:B19] >=7
and
IF [C2:C19] = Y, THEN COUNTIF [B2:B19] <7
Sorry if this is unclear or an obvious question!
One way to do this is to create three different measures
first countrows with filter on "Y" and similarly others - then you can bring these values on your bar chart

Alter variable format using SQR programming language

I am new to Peoplesoft and Peoplecode/SQR in general and I want to ask a question.
What I wish to do, is to try and output a large (clob) string variable on a PDF file using SQR programming language, on 3 columns on the page, just as you can change the layout of a text in Microsoft Word by going to Layout -> Columns -> Three
What I have until now is this:
begin-select
TXT.U_PO_TXT &TXT.PO_TXT
from PS_U_PO_DISC_TXT TXT
where TXT.BUSINESS_UNIT = &PO.BUSINESS_UNIT
and TXT.PO_ID = &PO.PO_ID
end-select
So,
TXT.U_PO_TXT
is a CLOB stored in the database of 10000 characters and I want to output
&TXT.PO_TXT
on the PDF using the layout described above.
I have tried using COLUMNS and NEXT-COLUMN SQR commands but to no avail.
I find the documentation of SQR on the Oracle website poorly written.
This is the example I have found, applied to my case:
columns 10 50 110
move 55 to #bottom_line
begin-select
TXT.U_PO_TXT &TXT.PO_TXT
if #current-line >= #bottom_line
next-column goto-top=1 at-end=newpage
else
position (+1,1) !what is this even, it throws me an error "Unknown command"
end-if
from PS_U_PO_DISC_TXT TXT
where TXT.BUSINESS_UNIT = &PO.BUSINESS_UNIT
and TXT.PO_ID = &PO.PO_ID
end-select
I couldn't find an answer anywhere. Please help me.
I don't think this is possible by using COLUMNS. Defining and printing to SQR columns determines where you start printing, but the text won't automatically wrap once it hits the end of the column. It'll just keep printing.
You can, however, use the WRAP parameter to PRINT to accomplish this. Here's an example
LET $left = 'This is the left column. This is the left column. This is the left column. This is the left column. This is the left column. This is the left column.'
LET $middle = 'This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column. This is the middle column.'
LET $right = 'This is the right column. This is the right column. This is the right column. This is the right column. This is the right column. This is the right column.'
! These variables are used to track which column is the tallest and then
! move the current position (#start-line) down by the largest number of
! lines that were printed
LET #line-offset = 0
LET #start-line = 1
LET #start-line-offset = #current-line - #start-line
! Print the left column
PRINT $left (#start-line, 1) WRAP 40 100
IF #current-line - #start-line-offset > #line-offset
LET #line-offset = #current-line - #start-line-offset
END-IF
! Print the middle column
PRINT $middle (#start-line, 50) WRAP 50 100
IF #current-line - #start-line-offset > #line-offset
LET #line-offset = #current-line - #start-line-offset
END-IF
! Print the right column
PRINT $right (#start-line, 110) WRAP 40 100
IF #current-line - #start-line-offset > #line-offset
LET #line-offset = #current-line - #start-line-offset
END-IF
! Update #start-line to be the original line position, plus the
! number of lines that were printed in the tallest column
LET #start-line = #start-line + #line-offset
PRINT 'Rest of the report goes here' (#start-line, 1)
The first number after WRAP is the character width of that column.
The second number after WRAP is the maximum number of lines that will be printed.
Most of the complexity in my code comes from that fact that you'll have to track which column printed the most lines (is the largest vertically) and then move your current cursor position down that many lines. The difficulty comes from that fact that your tallest column may be either the left or center column, so you need to track which column is your tallest rather than simply moving the cursor downward after printing your right column. In my example, the middle column is the tallest.
The reason I'm using #line-offset and #start-line-offset is because #current-line is the current line position in your report including the offset for the header. For example, if your header is 5 lines tall, then #current-line will start equal to 6 (the first line after your header) and doing PRINT 'hello' (#current-line, 1) will actually print to the 11th line of your report (6 lines down from the 5 line header). Also, assigning a value to #current-line doesn't seem to work, so I don't think your can manipulate the current line position directly.
If, however, you don't need to print anything else after your three columns, then you can use the KEEP-TOP parameter to WRAP so that your current line position doesn't change between each PRINT and you don't have to do any of the line offset tracking.
In your situation, you'll have to parse &TXT.PO_TXT into three separate variables (one for each column) based on how your text and column position data is stored in that field.
One thing to watch out for is that if you have two or more spaces in a row within the data you're printing, SQR may put a space as the first character of a line because word breaks seem to only be determined by the first space, rather than a sequence of one or more spaces.

Total length off all characters in all columns of each row

I'm new to SQL Server so I apologize if my question seems too easy. I tried finding and answer on my own, but I'm failing miserably. I am trying to create a query which will return total size on the drive of each row in the table.
i thought about using dbcc showconting but it doesn't work for varchar(max) which appears in my table. Also, it doesn't return size for each row, but rather the average, max and min size. My reading so far suggests that it is not possible to get query that could show the size of each individual row in the table so I decided to settle for the total length of all characters in each column in each row. Indirectly it will give me idea about the size of each row.
I have a table with some varchar(500) and varchar(max) columns. I noticed that some of the rows are a lot bigger than others.
What I need is top 1000 longest rows in the table, preferably in an output showing two columns:
Column 1 showing EntryID
Column 2 showing total length of the characters in all columns together for that record (eg total length of the characters in the column 1 + total length of the characters in the column 2 + column3 + column4 etc...) It would be great if this could be aliased RowLength.
What I tried so far is:
SELECT TOP 1000
(LEN(columnname1) + LEN(columnname2) + LEN(columnname3) + LEN(columnname4)) as RowLength,
FROM dbo.tablename
ORDER BY Length Desc
It works, but it doesn't show entry ID corresponding to the total length of all characters in the row. How do I add it?
It also doesn't show the alias for the column showing number of characters in the row.
Could you please suggest how I can change the query to get the expected outcome? I'll be very grateful for any suggestions.
it doesn't show EntryID corresponding to the total length of all
characters in the row. It also doesn't show the alias for the column
showing number of characters in the row.
You have not specified an alias, so what should it show? You also haven't selected EntryID. If you want the longest 1000 rows you have to order by the length:
SELECT TOP 1000
EntryID,
Length = LEN(columnname1) + LEN(columnname2) + LEN(columnname3) + LEN(columnname4)
FROM dbo.tablename
ORDER BY Length DESC
SELECT TOP 1000 EntryID,
(LEN(columnname1) + LEN(columnname2) + LEN(columnname3) + LEN(columnname4)) AS RowLength,
FROM dbo.tablename
ORDER BY EntryID

Resources