Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
thiendt5
Frequent Visitor

Separate duplicate values with order number by columns

Hello all!
I'm new to Power BI and I'm creating Error code tracking in Power BI.
Please help to see in below example:

I have the table below. Each IMEI is tested many times and generate many diffirent error codes:

thiendt5_0-1599802046259.png


Is there any DAX function formula could create new columns like this? I just want to show all error code of a IMEI by rows

thiendt5_1-1599802082049.png

 

I tried IF function but it didn't work
ERROR_1st = IF([Test_time]=1,[Error_code])
ERROR_2nd = IF([Test_time]=2,[Error_code])

The result i've got as below and I can't see all error code at a time when filtering:

thiendt5_2-1599802104243.png

 

Please suggest for this case. Thanks!

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @thiendt5 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

i1.png

 

You may create a calculated column as below.

ERROR_Num = 
SWITCH(
    'Table'[Test_time],
    1,"ERROR_1st",
    2,"ERROR_2nd",
    3,"ERROR_3nd", 
    4,"ERROR_4th",
    5,"ERROR_5th"
)

 

Then you may use 'Matrix' visual to display the result.

i2.png

 

Or you may create a calculated table with following dax.

Result Table = 
ADDCOLUMNS(
    DISTINCT('Table'[IMEI]),
    "ERROR_1st",
    CONCATENATEX(
        FILTER(
            'Table',
            [IMEI]=EARLIER('Table'[IMEI])&&
            [Test_time]=1
        ),
        [Error_code],
        " "
    ),
    "ERROR_2nd",
    CONCATENATEX(
        FILTER(
            'Table',
            [IMEI]=EARLIER('Table'[IMEI])&&
            [Test_time]=2
        ),
        [Error_code],
        " "
    ),
    "ERROR_3rd",
    CONCATENATEX(
        FILTER(
            'Table',
            [IMEI]=EARLIER('Table'[IMEI])&&
            [Test_time]=3
        ),
        [Error_code],
        " "
    )
)

 

Result:

i3.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @thiendt5 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

i1.png

 

You may create a calculated column as below.

ERROR_Num = 
SWITCH(
    'Table'[Test_time],
    1,"ERROR_1st",
    2,"ERROR_2nd",
    3,"ERROR_3nd", 
    4,"ERROR_4th",
    5,"ERROR_5th"
)

 

Then you may use 'Matrix' visual to display the result.

i2.png

 

Or you may create a calculated table with following dax.

Result Table = 
ADDCOLUMNS(
    DISTINCT('Table'[IMEI]),
    "ERROR_1st",
    CONCATENATEX(
        FILTER(
            'Table',
            [IMEI]=EARLIER('Table'[IMEI])&&
            [Test_time]=1
        ),
        [Error_code],
        " "
    ),
    "ERROR_2nd",
    CONCATENATEX(
        FILTER(
            'Table',
            [IMEI]=EARLIER('Table'[IMEI])&&
            [Test_time]=2
        ),
        [Error_code],
        " "
    ),
    "ERROR_3rd",
    CONCATENATEX(
        FILTER(
            'Table',
            [IMEI]=EARLIER('Table'[IMEI])&&
            [Test_time]=3
        ),
        [Error_code],
        " "
    )
)

 

Result:

i3.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Community Champion
Community Champion

@thiendt5 So maybe like the following:

Column = "ERROR_" & [Test_time]

You could then use that in a matrix visualization as the Column field. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@thiendt5 , You have pivot in power query. Otherwise, you have to create new column.

https://radacad.com/pivot-and-unpivot-with-power-bi

The option you want to try need filter and grouping. If pivot do not work

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak I'm sorry but pivot do not work. I created [Test_time] column by DAX so it can not be shown in Query Editor.

Could you suggest filter and grouping DAX function for this case?

@thiendt5 , you can create a new table using summarize 

like

summarize(Table, Table[itei] , ",ERROR_1st" ,maxX(Table, IF([Test_time]=1,[Error_code])) , "ERROR_2nd",maxX(Table, IF([Test_time]=2,[Error_code])))

 

Add other columns 

 

Or this how you can have new column in M/edit query

ERROR_1st = if [Test_time]=1 then [Error_code]


Then you can use aggregate column 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors