Keep leading zeros when joining data sources in tableau - tableau-api

I am trying to create a data source in Tableau (10.0) where I am joining a table from SQL with an Excel file. The join happens on a site id but when reading the id from the excel source, Tableau strips the leading zeros (and SQL keeps leading zeros). I see this example
to add the leading zeros back as a new, calculated field. But the join is still dropping rows because the id is not properly formatted when making the join.
How do I get the excel data source to read the column with the leading zeros so I can do the join?

Launch Excel and choose to open a new blank workbook.
Click the Data tab and select From Text.
Browse to the saved CSV file and select Import.
Ensure that Delimited is selected and click Next.
Leave Tab as the delimiter and click Next.
Select the column containing the data with leading zeros and click
Text.
Repeat for each column which contains leading zeros.
Click Finish.
Click OK.

Never heard of or used tableau, but it sounds as though something (jet/ace database driver being used to read excel file?) is determining the column to be numeric and parsing the data as numbers, losing leading zeroes
If your attempts at putting them back are giving you grief, I'd recommend trying the other direction instead; get sqlserver to convert its strings to numbers. Number matching should be more reliable than String matching, so long as the two systems don't handle rounding differently :)

If your Excel file was read in from a CSV and the Site ID is showing "Number Stored as Text", I think you can solve your problem by telling Tableau on the Data Source entry that the field is actually a string. On the preview data source view, change the "#" (designating number) to string so that both the SQL source and the Excel source are both strings before doing the join.

This typically has to do with the way Excel stores values as mentioned above. I would play around with the number formatting for the Site ID column in Excel itself, not Tableau, and changed that two "Text" in Excel. You can verify if Tableau will read it properly with the leading 0s by exporting your excel file to csv and looking in the csv files to see if the leading 0s are still there.

Related

Relative Date Item in Power Pivot GETPIVOT DATA excel function

I am using a GETPIVOTDATA function in Excel to source data from a pivot table generated by a Power BI query (everything was originally only in excel, the file got too large, so i stored the main tables in PBI but kept the reports in excel for mgmt's sake).
=GETPIVOTDATA("[Measures].["&$A$100&"]",'PIVOT Table_test'!$A$126,"[Master].[field1]","[Master].[field1].&["&C$26&"]","[Master].[AsofDate]","[Master].[AsofDate].&[2022-04-30T00:00:00]")
However, I want to make the GETPIVOTDATA function as dynamic as possible to prevent having too many hardcoded fields/items for each table that fields the charts we look at. However, when i reference the pivot table, the '[Asof]' field populates the static item as "...&[2022-04-30T00:00:00]")...
I have been trying to change that to reference a header row that contains a Short Date value (4/30/2022) like &["&$B&1"&"]")... but i keep getting #ref errors, every other field accepts the "&&" method, and when i leave the hardcoded timestamp in the formula, it populates.
So it has to be that reference but i do not understand what I am doing wrong. I have also tried changing the format of both the header row in Excel and the field within PBI but to no success.
Found the answer on another site. The solution in the item brackets is to write the following:
["&TEXT($A22,"yyyy-mm-dd""T00:00:00""")&"]

Copy data from Spreadsheet[LibreOffice Calc] to tables of Text Document[LibreOffice]

This was very interesting and challenging task for me. I want to copy data (1000s of rows with multiple columns) from Libre Office calc[spreadsheet] to the tables in Libre Office Writer[Text Document]. I spent almost a day to figure out the solution. Couldn't find the solution from any sites.
Copy the data[rows] from Spreadsheet.
Paste the same to the MS Word document[I did it by using Google docs as I'm using ubuntu].The table is created with rows and columns which is same as copied data.
Copy the table from word document and paste it in the Libre office Text Document.
Create the table with number of rows and columns Libre office Text Document.
Copy the table from Libre office Text Document[copied in point(3)] and paste in the table which is created in point(4).
NOTE / CAUTION : If you skip or alter any steps, it wont work.
Converting a column of text (perhaps from a screen-scrape of a online table) to a table format suitable for further work in a spreadsheet is easy if you have the traditional (locally installed) MS-Word program. The "Convert text to table" function there permits you to specify how many columns are in each record without having to edit your input files to manually place delimiters like commas, semi-colons, tabs etc. which is a PITA when you have to count rows to leave out the delimiter.
LibreOffice writer has a lightweight convert-text-to-table function which requires a lot of data conditioning before using it. In Libra Calc, Like any good spreadsheet, the "Transpose" function can be used to convert, say, 8 rows of the input column to a single 8-column row, but automating this requires macros or fixed templates.
So it is a non-trivial problem to duplicate that powerful capability in the old, locally installed MS-Word app, where users can take pages and pages of one-word data elements, and convert them into a "N" column table, where "N" is specified when you invoke the conversion in MS Word.

I am new to RegEx and need help pulling a string (sku) within a string in Tableau

The string is delimited by underscores and it could be as simple as taking the seventh _ and pulling the SKU from there. Ideally there would be a way of finding the text that looks like a SKU and pulling that out in tableau. I can't seem to figure out how to actually execute this.
Client_RT_Sample_PRODUCT_Men_Apparel_Hoodies_SMZM1047XL_160x600
Client_RT_Sample_PRODUCT_Men_Apparel_Hoodies_SMZM1047XXL_160x600
Client_RT_Sample_PRODUCT_Men_Apparel_Hoodies_SMZM1047XXL_300x250
Client_RT_Sample_PRODUCT_Men_Apparel_Hoodies_SMZM1047XXL_728x90
Client_RT_Sample_PRODUCT_Men_Sunglass_Lifestyle_DFPPBRMT_300x250
Client_RT_Sample_PRODUCT_Men_Sunglass_Lifestyle_DFPPBRMT_728x90
Client_RT_Sample_PRODUCT_Men_Sunglass_Lifestyle_DFRPGNMB_300x250
If this is an Excel or CSV file this is really easy with Tableau 9. In the Data Connection window click the arrow next column and select split or custom split. The latter will break it into as many separate fields as you want.

Excel 2010 - Pivot using external csv file - how to make dates work?

I have a set of pivot tables that use external csv files as their data sources. The csv files originally contained dates in the format dd/mm/yy (e.g. 31/01/13). The pivot tables did not recognise these as dates. I converted the dates in the csv files to dd/mm/yyyy (e.g. 31/01/2013) but these were still not recognised as dates by the pivot tables.
I tried setting up a calculated field =DATEVALUE(date_from_csv) but when used in the pivot table (I'm using the Max option to select the most recent date) I get #VALUE! errors.
I have tried converting the csv file to xlsx and also importing the data into the workbook that contains the pivot table - but I can't change from the external connection to use the internal data. I don't want to rebuild the pivots as there are a lot of variables and formatting that would take ages to redo.
Any ideas??
The problem was caused by the date column being blank for some rows and I found that if I moved a row to the top (after the header line) that had all the fields filled in, then Excel got the formats correct and the pivot tables now work!

sql developer export table to xls

How to export the entire query results to xls format without the value truncated (with the header intact).
e.g
the value is round up to 276408428673510000 when the actual value is suppose to be 276408428673508271
Using this method
After selecting the data by clicking 'Ctrl+ A' in gride, use 'Ctrl+Shift+C' to copy the data with Header. After pasting the data into MS Excel, try changing the 'format' to number or text. You must be knowing that 'format cells' is available as a right click option in MS Excel.
My solution was use the LPAD or RPAD functions, you give the exact length that you want and when you export the data, these don't round it.