Langsung ke konten utama

Pentaho Excel file creation with file name from field or other variable

https://stackoverflow.com/questions/49705813/pentaho-excel-file-creation-with-file-name-from-field-or-other-variable


Not knowing what your existing solution does, or why, this is the best way I can think of solving your problem, given you want exactly the same data in a different file format:

  1. Create a new job. In that job start a new transformation called 'get locations' your 'main' job with the get locations, and set variable and make excel

  2. In this 'get locations' transformation as below, have two steps a) Table input, with a query like 'select distinct locations from data' and b) copy rows to result. This should give you a list of your unique locations

Your first transformation, getting the locations with a select distinct

  1. Create another new job called 'set variable and make excel'. This job will be run after your 'get locations' transformation, tick the 'execute once for every row' checkbox

  2. In the new job, you'll have two transformations. set variable, and make excel. The second 'sub' job

  3. The set variable transformation has two steps, first 'gets rows from results' then 'set variables'. In set variables, set a new variable called 'out_filename' equal to the field 'Location'

setting the filename variable steps

  1. In the 'make excel' transformation, you have two steps, table input, and microsoft excel output making the excel files
  2. In the table input, run a query that uses your location variable (use the checkbox replace variables in script) eg. select * from data where Location = ${out_filename} Example settings for table input
  3. In the 'microsoft excel output' make the filename c:\yourPath\${out_filename}


Run the main job, this should work.

Komentar

Postingan populer dari blog ini

Mysql Import data from CSV File

  Microsoft Windows [Version 10.0.15063] (c) 2017 Microsoft Corporation. All rights reserved. C:\Users\PSI011>cd C:\xampp\mysql\bin C:\xampp\mysql\bin> mysqld 2017-08-22 14:24:49 15428 [Note] mysqld (mysqld 10.1.25-MariaDB) starting as process 16352 ... C:\xampp\mysql\bin> mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 10.1.25-MariaDB mariadb.org binary distribution Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> use pkh; Database changed MariaDB [pkh]> LOAD DATA LOCAL INFILE 'D:/2017/PKH_FOR_BPKP/PKH_FOR_BPKP_01.csv' -> INTO TABLE pkh_bpkp -> FIELDS TERMINATED BY ',' -> OPTIONALLY ENCLOSED BY '"' -> ESCAPED BY '"' -> LINES TERMINATED BY '\n...

CREATE CROSS TAB QUERY IN MYSQL

MySQL Multi-Aggregated Rows in Crosstab Queries MySQL’s crosstabs contain aggregate functions on two or more fields, presented in a tabular format. In a multi-aggregate crosstab query, two different functions can be applied to the same field or the same function can be applied to multiple fields on the same (row or column) axis. Rob Gravelle shows you how to apply two different functions to the same field in order to create grouping levels in the row axis. Today’s topic of discussion is crosstabs, which contain multiple aggregate functions in the row axis of a tabular resultset. Recall from the the  All About the Crosstab Query  article that an aggregate function is one that summarizes a group of related data in some way. Examples of aggregate functions include COUNT, SUM, AVG, MIN, and MAX. In a multi-aggregate crosstab query, two different functions can be applied to the same field or the same function can be applied to two or more fields. Today we’ll create a query...

Linux Basic Command Cheat Sheet

 https://www.guru99.com/linux-commands-cheat-sheet.html Linux Command Cheat Sheet In this Linux/Unix command line cheat sheet, you will learn: Basic Linux commands File Permission commands Environment Variables command User management commands of linux Networking command Process command VI Editing Commands Basic Linux commands Command Description ls Lists all files and directories in the present working directory ls -R Lists files in sub-directories as well ls -a Lists hidden files as well ls -al Lists files and directories with detailed information like permissions,size, owner, etc. cd or cd ~ Navigate to HOME directory cd .. Move one level up cd To change to a particular directory cd / Move to the root directory cat > filename Creates a new file cat filename Displays the file content cat file1 file2 > file3 Joins two files (file1, file2) and stores the output in a new file (file3) mv file "new file path" Moves the files to the new location mv filename new_file_name Re...