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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Two value in one row in matrix

Good morning,
I have a situation like this:

tarz_0-1606892307367.png

 

 

and I'm replicating it as a matrix.
But I was asked if I can change the view to this:

tarz_1-1606892320262.png

 

how can i put two values in a field aligned in the center?

or, if I can't do the above, I wish I could replicate a situation like this:

tarz_2-1606892333747.png

How can I put a space before the field name?

 

thanks everyone for the help

 

Best regards

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

Hi, @Anonymous 

 

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

Table:

c1.png

 

KPI:

c2.png

 

Then you need to make 'KPI1', 'KPI2', 'KPI3' selected and unpivot them.

c3.png

 

There is no relationship between tables. You may create a measure as below.

Result = 
var t = 
ADDCOLUMNS(
    CROSSJOIN(
        DISTINCT('KPI'[New KPI]),
        DISTINCT('Table'[Year])
    ),
    "Result",
    IF(
        [New KPI]="KPI1",
        CONCATENATEX(
            FILTER(
                ALL('Table'),
                [KPI] in {"KPI1","KPI2"}&&
                [Year]=EARLIER('Table'[Year])
            ),
            [Value],
            UNICHAR(10)
        ),
        CONCATENATEX(
            FILTER(
                ALL('Table'),
                [KPI]=EARLIER('KPI'[New KPI])&&
                [Year]=EARLIER('Table'[Year])
            ),
            [Value],
            UNICHAR(10)
        )
    )
)
return
CONCATENATEX(
    t,
    [Result],
    UNICHAR(10)
)

 

Result:

c4.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

3 REPLIES 3
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

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

Table:

c1.png

 

KPI:

c2.png

 

Then you need to make 'KPI1', 'KPI2', 'KPI3' selected and unpivot them.

c3.png

 

There is no relationship between tables. You may create a measure as below.

Result = 
var t = 
ADDCOLUMNS(
    CROSSJOIN(
        DISTINCT('KPI'[New KPI]),
        DISTINCT('Table'[Year])
    ),
    "Result",
    IF(
        [New KPI]="KPI1",
        CONCATENATEX(
            FILTER(
                ALL('Table'),
                [KPI] in {"KPI1","KPI2"}&&
                [Year]=EARLIER('Table'[Year])
            ),
            [Value],
            UNICHAR(10)
        ),
        CONCATENATEX(
            FILTER(
                ALL('Table'),
                [KPI]=EARLIER('KPI'[New KPI])&&
                [Year]=EARLIER('Table'[Year])
            ),
            [Value],
            UNICHAR(10)
        )
    )
)
return
CONCATENATEX(
    t,
    [Result],
    UNICHAR(10)
)

 

Result:

c4.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.

AllisonKennedy
Super User
Super User

How is the raw data? Is it all in one table? Do you have a Category table that shows that KPI 1 and KPI 2 are part of the same category? If you have this, you could use the stepped layout in matrix to Off, and set Category and KPI as rows. 

 

For example add a table like: 

Category KPI
A KPI 1
A KPI 2
B KPI 3

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

@AllisonKennedy thnak for your answer. I have this situatione in my table:

tarz_0-1606908087938.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.