Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

How to dynamically change column field names ? (For: Google Analytics goal types)

Hello,

 

I am reporting some Google Analytics data, and I am struggling to dynamically change gol types (e.g: 1 and 2) into their corresponding conversion names at account level.

 

My objective is to display  a pie chart by goal types with the corresponding conversion label name. And  dynamically change label names when filtering by account type.

 

 

I have tried to use this DAX: (However is not working):

 

Goal Types = IF(('All Data'[Account]="Random1" && 'All Data'[Data Source]="GA Main Website Accounts" && 'All Data'[Goal 1]>0), "Hero customer form submission",
IF(('All Data'[Account]="Random1" && 'All Data'[Data Source]="GA Main Website Accounts" && 'All Data'[Goal 2]>0), "Product find out more CTA",
IF(('All Data'[Account]="Random2" && 'All Data'[Data Source]="GA Main Website Accounts" && 'All Data'[Goal 1]>0), "Apply now CTA",
IF(('All Data'[Account]="Random2" && 'All Data'[Data Source]="GA Main Website Accounts" && 'All Data'[Goal 2]>0), "Discover more CTA",

IF(('All Data'[Account]="Random3" && 'All Data'[Data Source]="GA Main Website Accounts" && 'All Data'[Goal 1]>0), "Lead generation sign up form",

IF(('All Data'[Account]="Random3" && 'All Data'[Data Source]="GA Main Website Accounts" && 'All Data'[Goal 2]>0), "Find your car CTA","Other"))))

 

Please somone can help me with this?

 

I have attached a sample data source here:

 

https://docs.google.com/spreadsheets/d/1BRcYbk4lSt4gpTIT61aJB2k1x9x-n4DN8L7igcjqkeg/edit?usp=sharing

 

 

 

 

 

 

 

10 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous,

    AFAIK, current power bi does not support create dynamic calculated column/table based on filter/slicer effect.

    If you mean dynamic change the visual titles, you can create a measure and setting the visual title based on expressions results.

    Expression-based titles in Power BI Desktop - Power BI | Microsoft Docs

    Notice: the data level of power bi.

    Database(external) -> query table(query, custom function, query parameters) -> data model table(table, calculate column/table) -> data view with virtual tables(measure, visual, filter, slicer)

    Regards,

    Xiaoxin Sheng

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for your help. But is not what I am looking for. 

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous,
        So you mean to group your records based on fields value and assign specific categories instead of change field names? If that is the case, you can try to use the following DAX formulas:

        Goal Types =
        IF (
            'All Data'[Data Source] = "GA Main Website Accounts",
            SWITCH (
                'All Data'[Account],
                "Random1",
                    IF (
                        'All Data'[Goal 1] > 0,
                        "Hero customer form submission",
                        IF ( 'All Data'[Goal 2] > 0, "Product find out more CTA", "Other" )
                    ),
                "Random2",
                    IF (
                        'All Data'[Goal 1] > 0,
                        "Apply now CTA",
                        IF ( 'All Data'[Goal 2] > 0, "Discover more CTA", "Other" )
                    ),
                "Random3",
                    IF (
                        'All Data'[Goal 1] > 0,
                        "Lead generation sign up form",
                        IF ( 'All Data'[Goal 2] > 0, "Find your car CTA", "Other" )
                    )
            )
        )

        Regards,
        Xiaoxin Sheng

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous  Thank yoiu for sharing this, I have already seen this video and in my case I am using a table union which is including different accounts for which changing naming for Goal 1 or 2 or others may not be beneficial as goal types may have different goal names based on a specific Account.