Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

How to transform this data and keep correct data model

 

Hi Community,

 

I would like to transform my dataset as shown in image below.

 

Example

 

Could anyone help? 

Thanks a lot in advance!

  • Hi Anonymous 

    Create a employee table without any relationship with your table.

    employee table = VALUES('Table 2'[Employee])

    Create measures

    selected = CONCATENATEX(ALLSELECTED('employee table'),'employee table'[Employee],",")
    
    filtered = FIND(MAX('Table 2'[Employee]),[selected],1,0)
    
    total_hours = var sums=CALCULATE(SUM('Table 2'[Hours]),FILTER(ALLSELECTED('Table 2'),'Table 2'[Client]=MAX('Table 2'[Client]))) return IF([filtered]=1,sums)
    
    col_emp = var con=CONCATENATEX(FILTER(ALLSELECTED('Table 2'),'Table 2'[Client]=MAX('Table 2'[Client])),[Employee],",") return IF([filtered]=1,con)

    Best Regards
    Maggie
    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • v-juanli-msft's avatar
    v-juanli-msft
    Community Support

    Hi Anonymous 

    Create a employee table without any relationship with your table.

    employee table = VALUES('Table 2'[Employee])

    Create measures

    selected = CONCATENATEX(ALLSELECTED('employee table'),'employee table'[Employee],",")
    
    filtered = FIND(MAX('Table 2'[Employee]),[selected],1,0)
    
    total_hours = var sums=CALCULATE(SUM('Table 2'[Hours]),FILTER(ALLSELECTED('Table 2'),'Table 2'[Client]=MAX('Table 2'[Client]))) return IF([filtered]=1,sums)
    
    col_emp = var con=CONCATENATEX(FILTER(ALLSELECTED('Table 2'),'Table 2'[Client]=MAX('Table 2'[Client])),[Employee],",") return IF([filtered]=1,con)

    Best Regards
    Maggie
    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.