Forum Discussion

NicoH's avatar
NicoH
Regular Visitor
4 years ago

Need help on DAX function

Hi everyone

I'm confused by the DAX function. I want to compare the budget and contract amount based on a table with the budget and contract info with the columns like BudgetID, Year, Budget Amount, ContractID, and Contract Amount.

Now the result like

If removed SUM on budget amount,

 

 

 

 

 

 

I think it sums up the budget amount on different contracts.

So How to sum up the budget amount without the contract ID?

 

 

 

18 Replies

  • NicoH Hi,
    I am not sure I completely get your result, but you can use SUMX to iterate through the whole table and get the whole sum. 

    SUMX('Table', [budget amount])

    Please, if I get it wrong, share your copyable dataset and result, thank you.

    • NicoH's avatar
      NicoH
      Regular Visitor

      Hi vojtechsima

      Thanks for your tip.

      Please find the sample data

      budgetIDYeardepartmentbudgetAmount
      1102021IT4900
      1102022IT4700
      2002021HR1000
      2002022HR2000

       

      budgetIDYearcontractIDcontractAmount
      1102021c1100
      1102022c2200
      1102021c3300
      1102022c4400
      1102023c130
      2002021HR-C1100
      2002022HR-C1200
      2002022HR-C2500

       

       

      THe expected result

      YearDepartmentBudgetAmountContractAmount
      2021IT4900400
      2022IT4700600
      • v-janeyg-msft's avatar
        v-janeyg-msft
        Community Support

        Hi, NicoH 

         

        Are you sure that the columns on the dimension table are all placed in the table?

         

         

  • NicoH's avatar
    NicoH
    Regular Visitor

    Hi  I tried your suggestion but no luck.

    I have 2 tables: Budget and Contract. 

    Budget Table

    budget id | Year | budget amount

    110 | 2021 | 4900

    110 | 2022 | 4710.4 

     

    Contract Table

    BudgetID | contract ID | Year | contract amount

    110          | c1               | 2021|  100

    110          | c2               | 2021|  200

    110          | c3               | 2022|  300

    110          | c4               | 2022|  400

     

    The result I want likes:

    Budget ID | Year | Budget Amount | Contract Amount 

    110           | 2021| 4900                   | 300

    110           | 2022| 4710.4                | 700

     

    Thanks in advance.

    voji

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

      Hi, NicoH 

       

      I checked your model, your two tables have many-to-many relationships, what you need is to establish a master-slave table to improve the data model.

      You can use distinct function to create single tables as slave table. According to the information you provide, you need to set a one-to-many relationship between budget id and year.

      Like this:

      Table = DISTINCT('Budget Table'[budget id])
      Table 2 = DISTINCT('Budget Table'[Year])

      Then you need to use slave table budget id and year and master columns in visual.

       

      Did I answer your question? Please mark my reply as solution. Thank you very much.
      If not, please feel free to ask me.

      Best Regards,
      Community Support Team _ Janey

      • NicoH's avatar
        NicoH
        Regular Visitor

        Hi Janey

        Your solution works for the budget amount, but the contract amount does not work