I am trying to count unique ID numbers in Tableau; however, when I filter by year, there are some years with no ID numbers. As a result, I want the number 0 to be shown, but instead Tableau just displays a blank. I was trying to use a calculated field like this, but it doesn't seem to be working.
IF(COUNTD([ID]) > 0) THEN COUNTD([ID])
ELSE 0
END
Alternatively, I tried this, but it also doesn't work.
IF ISNULL(COUNTD([ID])) THEN 0
ELSE COUNTD([ID])
END
Here is what the worksheet looks like. It is very simple.
Filtering out some of the years, you can see how the zero values are simply displayed as blanks.
You can use ZN()function for this.
ZN(CountD[ID]))
Related
I have a data frame that looks kind of like this...but much larger
I want to look at the record_id column and shift the right side columns down when the row says admin_time. Then make that previous row NA. Then when I write it to a csv, I'll just use the na = "" to make those cells blank
For example, in the first few rows, it would look like this...
No need to try to recreate the data frame. I was thinking maybe a for loop would work with an embedded if statement to review the patient_id, record_id, and pk_day. I was just looking for alternate suggestions or how to use a statement within the loop to pick out the admin line and do what I mentioned above
I have a GridView which I plan to add different colors in each row based on certain conditions.
One such condition is to color the row in a specific color if a number in column 6 is higher than the number in column 7.
If e.Row.Cells(6).Text > e.Row.Cells(7).Text Then
e.Row.BackColor = ColorTranslator.FromHtml("#FDD533")
Else
However, when I test the code it seems to only change the color when the left most value in column 6 is larger than column 7, regardless of the fact that column 6 is in the hundreds, while column 7 is in the thousands.
I believe the cause is coming from me using text in the If statement. However, any instance of number I can think to change doesn't seem to fit into the code:
If e.Row.Cells(6).Number > e.Row.Cells(7).Number Then
or
If e.Row.Cells(6).Integer > e.Row.Cells(7).Integer Then
These example gives me a message saying
'Number' is not a member of 'System.Web.UI.WebControls.TableCell'
What else can I use that is compatible with the current code?
I believe that you are missing a casting. I'm not sure if you're comparing only Integers or complex numbers, if you don't know I recommend you to cast directly to doubles:
If Convert.ToDouble(e.Row.Cells(6).Text) > Convert.ToDouble(e.Row.Cells(7).Text) Then
e.Row.BackColor = ColorTranslator.FromHtml("#FDD533")
Else
Convert.ToDouble will convert any text to number.
More info about casting:
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/types/how-to-convert-a-string-to-a-number
https://www.dotnetheaven.com/article/casting-integer-to-long-single-and-double-using-vb.net
If you might have some empty values you can use the TryCast:
https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/trycast-operator
I am using PHPExcel_v1_8, I have implemented formula to some cells like following.
$objPHPExcel->getActiveSheet()->SetCellValue('G4','=SUBTOTAL(2,B6:B'.$row.')');
$objPHPExcel->getActiveSheet()->SetCellValue('H4','=ROUND(SUBTOTAL(9,Q6:Q'.$row.'),2)');
I also tried like
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6,4,'=SUBTOTAL(2,B6:B'.$row.')');
Here $row means total number of rows.
But when I filter any column then it append/override value of formula applied cell. Please see following filtered total row.
I want only latest value should in filtered total row means want to replace existing value. Right now, I am getting correct value but why it is overrided? Any suggestions what can be the solution?
You've actually discovered a genuine bug here.
I wasn't aware when I implemented the SUBTOTAL logic in PHPExcel that it only worked with visible rows, and ignored hidden rows. Can you please raise an issue on the github repo
However, reading through the MS Excel docs for SUBTOTAL, a function of 2 or 9 will return the result for all rows in the range (hidden or otherwise) while 102 or 109 will return the result only for visible rows
I am trying to customize a report for stock status in our warehouse.
The current report does not total the number of pallets so I added a spot to count the number of movable units.
The problem is once an order is shipped out the line item still stays on the report but the qty available of pieces goes blank since nothing is there.
So I want to make it that I can Count the qty available if it is greater than 0 and I want to count 1 if it is less than 1 but I don't want it to count anything.
I have tried all sorts of combinations and can't get it right.
I think if I understand right that i need to do something like
=COUNT(IIF(Fields!SUMOFONHAND.Value>0)=1.(IIF(Fields!SUMOFONHAND.Value<1)=0
IIF works like this: IIF(expression, true, false)
So you want this:
=SUM(IIF(Fields!SUMOFONHAND.Value > 0, 1, 0))
I have a spreadsheet called "MTM Lookup", this is downloaded from a specific site, in column D of this spreadsheet are values, but these values have a formula attached to them. The formula rounds these values to 0. The formulas don't round on a specific cell. They look like this =ROUND(35370.6708773751,0) or =ROUND(48368.0427161566,0). I need the values to come through with all the decimals or rounded to 10 decimals but cannot get this to happen, I can remove the formula and leave the value but it is rounded to zero. Please could anyone assist with some simple vba to either remove the =round(,0) or replace the 0 to 10 ie round(x,10).
I don't see any problem in the formula you provided.
When I put
=ROUND(35370.6708773751,0)
to a cell, I correctly see 35371 in the cell.
There are, however, two things in play here.
Formula
Cell Format
For example, when I enter the following value to the cell:
=ROUND(35370.6708773751,10)
I do see 35370.67088 as a result (after rounding to 10 places, cell format rounds it again to 5 decimal places)
I don't know why entering the value without any formula shows you 0, but this leads me to the same suspscion, i. e. that the problem is in the cell format.
You can check it by right clicking on the cell > Format Cells (in office 2010 at least) or programatically, using the following, for example:
sheets("MTM Lookup").range("A:1").numberformat = "0.0000000000"
Hope that it helps.