Search code examples
powerbidax

How to combine two rows values into one in power bi using DAX and not in Power Query?


I have a table with name "Business Unite" as below -

Business Unit
A.1
A.2
A.3
B
C

I want the values for the rows A.1, A.2 and A.3 to be as A only. The new table should look like the below example -

Business Unit
A
B
C

I have tried the below DAX expression but obviously, it has an error -

Business Unite Measure = 
CALCULATETABLE( 'Events', 
        SWITCH( 'Events'[Business Unit], 
                "A.1", "A",
                "A.2", "A",
                "A.3", "A",
                "B", "B",
                "C", "C", BLANK() ) )

The desired table is achievable in Power Query but is there any way to get the result using DAX?


Solution

  • Create a new column in table (note that should be column not measure):

    Business Unit2 = 
    SWITCH( [Business Unit], 
    "A.1", "A",
    "A.2", "A",
    "A.3", "A",
    "B", "B",
    "C", "C", BLANK() ) 
    

    Then you can use this new column as X-axis & other value measures as Y-axis to any visuals.