Forum Discussion

Devesh's avatar
Devesh
Frequent Visitor
4 years ago
Solved

Create Summarize table with DAX

Hello All,

 

I want to create a calculated table using 2 existing tables in Power BI.
1st table:

namepercentagedate
a20%01-10-2021
b30%01-10-2021
c40%01-10-2021
d10%01-10-2021

 

2nd table:

categoryamountdate
one50001-10-2021
two100001-10-2021
three150001-10-2021

 

Output:

namecatamountdate
aone10001-10-2021
bone15001-10-2021
cone20001-10-2021
done5001-10-2021
atwo20001-10-2021
btwo30001-10-2021
ctwo40001-10-2021
dtwo10001-10-2021
athree30001-10-2021
bthree45001-10-2021
cthree60001-10-2021
dthree15001-10-2021

 

I want the "amount" from the 2nd table to be distributed using the "percentage" column in the 1st table. Please help. Thanks in advance.

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Devesh,

    I created a sample pbix file(see attachment), please check whether that is what you want. First, Please create the relationship for Table1 and Table2 base on date fields...

    Create relationship base on date fields

    1. If you want to get a summarized table, you can create a calculated table with following DAX formula:

    Output = 
    SUMMARIZECOLUMNS (
        'Table1'[name],
        'Table2'[category],
        'Table1'[date],
        "amount", SUM ( 'Table1'[percentage] ) * SUM ( 'Table2'[amount] )
    )

    2. If you just want to display as a table visual, you can simply create a measure as below. 

    NAmount = SUM('Table1'[percentage])*SUM('Table2'[amount]) 

    Best Regards

3 Replies

  • bcdobbs's avatar
    bcdobbs
    Community Champion

    In the data you give everything has the same date.

    In your real data are the two table related on date column?

     

     

    • Devesh's avatar
      Devesh
      Frequent Visitor

      Yes, they are related on date column. As we add data for next month, it should be filtered by date column.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Devesh,

        I created a sample pbix file(see attachment), please check whether that is what you want. First, Please create the relationship for Table1 and Table2 base on date fields...

        Create relationship base on date fields

        1. If you want to get a summarized table, you can create a calculated table with following DAX formula:

        Output = 
        SUMMARIZECOLUMNS (
            'Table1'[name],
            'Table2'[category],
            'Table1'[date],
            "amount", SUM ( 'Table1'[percentage] ) * SUM ( 'Table2'[amount] )
        )

        2. If you just want to display as a table visual, you can simply create a measure as below. 

        NAmount = SUM('Table1'[percentage])*SUM('Table2'[amount]) 

        Best Regards