How to create template using multiple datasets for dashboard migration

Hi All,
I’m migrating the dashboards from one account to another account,
I’m trying to create the template in account A,
but each visual depending up on a different dataset, How can I add the multiple datasets in a JSON template,

{
"AwsAccountId": "92xxxxxxxx", 
 "TemplateId": "test-template", 
 "Name": "Test Template", 
 "SourceEntity": {
     "SourceAnalysis": {
         "Arn": "arn:aws:quicksight:us-east-1:92xxxxxxxx:analysis/38765ffd-80a5-xxxxxxxxxx", 
         "DataSetReferences": [
             {
                 "DataSetPlaceholder": "test-data-set1", 
                 "DataSetArn": "arn:aws:quicksight:us-east-1:92xxxxxxx:dataset/248a9365-c91d-4bb0-93c8-xxxxxxxxxx"
             }
         ]
     }
 }, 
 "Tags": [
     {
         "Key": "Name", 
         "Value": "Test Template"
     }
 ], 
 "VersionDescription": "1"
}

I have 4 sheets from the dashboard, which one should I place in analysis ID ( Arn": "arn:aws:quicksight:us-east-1:92xxxxxxxx:analysis/38765ffd-80a5-xxxxxxxxxx) , sheet ID or analysis ID…?
One more question,
data base which we use in Account A for visual creation, it should be present in Account B…?

hi @suresh1

last November, QuickSight released new set of APIs which allows to have all the visual information exported with JSON format. you can use those APIs to see how multiple datasets are handles in each visuals as well as sheet information. with these APIs, you can export dashboard and import into another account as well. the details of APIs are described in blog : New Amazon QuickSight API Capabilities to Accelerate Your BI Transformation | AWS News Blog

as for database you use in account A, it depends on what database you are using. if you are using Redshift or RDS, cross account access is supported and the below is blog.

Thanks Wakana,
I have created the template like this, but It is not working

{
“AwsAccountId”: “92xxxxxxxxxx”,
“TemplateId”: “LCA-Dashboard”,
“Name”: “LCADashboard”,
“SourceEntity”: {
“SourceAnalysis”: {
“Arn”: “arn:aws:quicksight:ap-northeast-1:92xxxxxxxxxx:analysis/71306a25-c762-4b8b-xxxxxxxxxxxxxx”,
“DataSetReferences”: [
{
“DataSetPlaceholder”: “lca-data-set”,
“DataSetArns”: [
“arn:aws:quicksight:ap-northeast-1:92xxxxxxxxxx:dataset/66e1bc10-8664-4f2c-xxxxxxxxxxxxxxx”,
“arn:aws:quicksight:ap-northeast-1:92xxxxxxxxxx:dataset/360d1045-1fe7-415d-xxxxxxxxxxxxxxxx”,
“arn:aws:quicksight:ap-northeast-1:92xxxxxxxxxx:dataset/70abba45-673d-4bda-xxxxxxxxxxxxxxxx”,
“arn:aws:quicksight:ap-northeast-1:92xxxxxxxxxx:dataset/5b637e9e-d239-4a1f-xxxxxxxxxxxxxxxx”,

                ]
             }
         ]
     }
 }, 

 "VersionDescription": "1"
}

I think you have to create “DataSetPlaceholder”: and “DataSetArns”: for the number of datasets in list structure.

HI @suresh1 ,

Here is an example template

{
    "AwsAccountId": "XXXX",
    "TemplateId": "360-Multi-Dataset-Template",
    "Name": "360-Multi-Dataset-Template",
    "SourceEntity": {
        "SourceAnalysis": {
            "Arn": "arn:aws:quicksight:eu-central-1:XXXX:analysis/ef9a768b-9716-43de-b47c-189d3fea5e96",
            "DataSetReferences": [
                {
                    "DataSetPlaceholder": "360",
                    "DataSetArn": "arn:aws:quicksight:eu-central-1:XXXX:dataset/b55d4bcd-c2aa-4fa6-be13-0d3601a208ea"
                },
                {
                    "DataSetPlaceholder": "360-1",
                    "DataSetArn": "arn:aws:quicksight:eu-central-1:XXXX:dataset/0760f121-0b6a-44b6-8060-6b5ac5f8c927"
                },
                {
                    "DataSetPlaceholder": "360-2",
                    "DataSetArn": "arn:aws:quicksight:eu-central-1:XXXX:dataset/2e02c7b8-5d3a-46b2-9198-6f5668e8c34e"
                }
            ]
        }
    },
    "VersionDescription": "1"
}


Additionally the following blog provides more details regarding migrating an asset from account A to account B : Migrate Amazon QuickSight across AWS accounts | AWS Big Data Blog

Regards,
Koushik

Thanks @Koushik_Muthanna ,
I have created same format, but I’m getting some error,
How can I troubleshoot the issue , I have 39 datasets
{
“Status”: 200,
“Template”: {
“Arn”: “arn:aws:quicksight:ap-northeast-1:92xxxxxxx:template/LCA-Dashboard1”,
“Name”: “LCADashboard”,
“Version”: {
“CreatedTime”: “2023-01-24T19:11:50.486000+09:00”,
“Errors”: [
{
“Type”: “DATA_SET_NOT_FOUND”,
“Message”: “Datasets are not found”
}
],
“VersionNumber”: 1,
“Status”: “CREATION_FAILED”,
“Description”: “1”,
“Sheets”:
},
“TemplateId”: “LCA-Dashboard1”,
“LastUpdatedTime”: “2023-01-24T19:11:50.479000+09:00”,
“CreatedTime”: “2023-01-24T19:11:50.479000+09:00”
},
“RequestId”: “0cd3b93e-b0c0-4dc8-9f9a-70f79b9dxxxx”

@suresh1 Follow this Steps
Create a template from analysis with bellow json and command

aws quicksight create-template --region us-east-1  --cli-input-json "file:///{project-dir}/{quicksight}/{filname}.json"
{
    "AwsAccountId": "{{account_id}}",
    "TemplateId": "templateId",
    "Name": "Name of your dashboard (V1)",
    "SourceEntity": {
        "SourceAnalysis": {
            "Arn": "arn:aws:quicksight:us-east-1:{{account_id}}:analysis/{{analysis_id}}",
            "DataSetReferences": [
                {
                    "DataSetPlaceholder": "dataset name 1",
                    "DataSetArn": "arn:aws:quicksight:us-east-1:{{account_id}}:dataset/{{id}}"
                },
                {
                    "DataSetPlaceholder": "dataset name 2",
                    "DataSetArn": "arn:aws:quicksight:us-east-1:{{account_id}}:dataset/{{id}}"
                },
                {
                    "DataSetPlaceholder": "dataset name 3",
                    "DataSetArn": "arn:aws:quicksight:us-east-1:{{account_id}}:dataset/{{id}}"
                },
                {
                    "DataSetPlaceholder": "dataset name 4",
                    "DataSetArn": "arn:aws:quicksight:us-east-1:{{account_id}}:dataset/{{id}}"
                }
            ]
        }
    },
    "VersionDescription": "1"
}

Upon Success, you will get status 202 with ARN
Note that ARN

Now wait a little bit, Make sure the template is created, you can use describe-template to see if the above template is created or not. Then create a dashboard with that template with this command and json file.

aws quicksight create-dashboard --cli-input-json "file:///{{project-dir}}/quicksight/{{dashboard-template}}.json"
{
    "AwsAccountId": "380845196104",
    "DashboardId": "8bad1afa-83ea-4772-a753-50666afb9622",
    "Name": "CollegiateSchool-V1",
    "Parameters": {
        "StringParameters": [{
            "Name": "qRiskiestUserName",
            "Values": ["Alpa Chino"]
        }]
    },
    "SourceEntity": {
        "SourceTemplate": {
            "DataSetReferences": [
                {
                    "DataSetPlaceholder": "dataset name 1",
                    "DataSetArn": "{{arn}}"
                },
                {
                    "DataSetPlaceholder": "dataset name 2",
                    "DataSetArn": "{{arn}}"
                },
                {
                    "DataSetPlaceholder": "dataset name 3",
                    "DataSetArn": "{{arn}}"
                },
                {
                    "DataSetPlaceholder": "dataset name 4",
                    "DataSetArn": "{{arn}}"
                }
            ],
            "Arn": "{{template-arn-you-got-above}}"
        }
    },
    "Tags": [{
        "Key": "template",
        "Value": "whatever"
    }],
    "VersionDescription": "V1",
    "ThemeArn": "arn:aws:quicksight::aws:theme/RAINIER"
}