Forum Discussion

PietroP's avatar
PietroP
New Member
4 years ago
Solved

Wrong column total relationing two tables

Hi everyone,
i have two tables:

 

table1:
SiteCode,

Work_ID,
Date_Of_Work

 

ex:

work_IDSiteCodedate_of_work
2021CF000030D0312511/03/2021 00:00
2019CF000017D0001919/09/2019 00:00
2019CF000089D0237004/12/2019 00:00
2020CF000023D0245429/01/2020 00:00
2019CF000074D0233615/11/2019 00:00
2019CF000098D0239816/12/2019 00:00
2020CF000034D0261521/02/2020 00:00
2020CF000104D0283504/08/2020 00:00
2020CF000019D0167931/01/2020 00:00
2020CF000018D0244528/01/2020 00:00
2020CF000020D0154331/01/2020 00:00

 

 

table2:

SiteCode,
TOTKW

 

Ex:

SiteCodeTOTKW
D03125950
D00019948
D02370576
D02454491
D02336300
D02398250
D02615249
D02835222
D01679215
D02445200
D01543150

 

I made a relationship many-to-one between the two tables (table1 to table2) on SiteCode and I need to get a table with SiteCode, Work_ID, Date_Of_Work, and TOTKW

 

The problem is that TOTKW field total is not the sum of the row values displayed.
I tried to solve creating a new column in table two with this formula:

NewColumn = calculate (sumx(Table2,Table2[TotKW]) )
But it didn't work

Can you please hel me?

Thank you

  • Anonymous's avatar
    Anonymous
    4 years ago

    PietroP 

    You may just create a column in Table 1 to get the TOTKW from table2, this should be more clear to you.

    TOTKW = Related(table2[TOTKW])

     

    Then you can just create measure or column with simply sum.
    measure = sum(table1[TOTKW])

     

     

    Best regards
    Paul Zheng _ Community Support Team
    If this post helps, please Accept it as the solution to help the other members find it more quickly.

4 Replies

  • PietroP , Try like

    NewColumn = calculate (sumx(values(Table2[Sitecode]),calculate(Max(Table2[TotKW]) )))

     

    Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

    • PietroP's avatar
      PietroP
      New Member

      Thank you for your suggestion. It didnt work, I still have the same total.

      I updated my first post pasting real datas about the two tables. Hope it could help.

      Tell me if you need anything different.

      Thanx

  • Hi PietroP 

     

    Try this:

     

    Measure = sum('Table 2'[TOTKW])
     

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

    Appreciate your Kudos!!


  • Anonymous's avatar
    Anonymous
    Not applicable

    PietroP 

    You may just create a column in Table 1 to get the TOTKW from table2, this should be more clear to you.

    TOTKW = Related(table2[TOTKW])

     

    Then you can just create measure or column with simply sum.
    measure = sum(table1[TOTKW])

     

     

    Best regards
    Paul Zheng _ Community Support Team
    If this post helps, please Accept it as the solution to help the other members find it more quickly.