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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Uki
Frequent Visitor

how to summarize table and pick values for new columns

I know that it's basics, but having no background I could not have found a solution for my problem even though I have researched for a while.

Lets say I have a table:

link_idpipelineowner_initials
11AA
12BB
21CC
22DD
31AA
32DD


and what I want to get is a table like:

link_idSDRKAM
1AABB
2CCDD
3AADD


(SDR is owner_initials for pipeline 1, KAM is owner_initials for pipeline 2).

What is the most elegant way to do it either in M or DAX?

Thank you!
Łukasz

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Uki 
Please refer to sample file https://www.dropbox.com/t/tkYPptvUVdvfRvr1

SDR = 
CALCULATE (
        SELECTEDVALUE ( 'Pipe line'[owner_initials] ),
        'Pipe line'[pipeline] = 1
)
KAM = 
CALCULATE (
        SELECTEDVALUE ( 'Pipe line'[owner_initials] ),
        'Pipe line'[pipeline] = 2
)

1.png

View solution in original post

4 REPLIES 4
Uki
Frequent Visitor

This is what i did by myself, but I did not come up with this part:

'Table'[link_id] = EARLIER( [link_id] )

 
Reading abou EARLIER now. Not that obvious at my level 😞

tamerj1
Super User
Super User

Hi @Uki 
Please refer to sample file https://www.dropbox.com/t/tkYPptvUVdvfRvr1

SDR = 
CALCULATE (
        SELECTEDVALUE ( 'Pipe line'[owner_initials] ),
        'Pipe line'[pipeline] = 1
)
KAM = 
CALCULATE (
        SELECTEDVALUE ( 'Pipe line'[owner_initials] ),
        'Pipe line'[pipeline] = 2
)

1.png

Uki
Frequent Visitor

Thank you! Works!

VahidDM
Super User
Super User

Hi @Uki 

 

Try this code to add a new table with DAX:

 

New Table = 
ADDCOLUMNS(
    VALUES( 'Table'[link_id] ),
    "SDR",
        CALCULATE(
            MAX( 'Table'[owner_initials] ),
            FILTER(
                'Table',
                'Table'[link_id] = EARLIER( [link_id] )
                    && 'Table'[pipeline] = 1
            )
        ),
    "KAM",
        CALCULATE(
            MAX( 'Table'[owner_initials] ),
            FILTER(
                'Table',
                'Table'[link_id] = EARLIER( [link_id] )
                    && 'Table'[pipeline] = 2
            )
        )
)

 

Output:

 

VahidDM_0-1648079821324.png

 

 

 

 

Sample file attached.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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