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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
drgrundy
Frequent Visitor

Sum all Related Records and Multiply by a Column in a Related Table

1) I have a table of billing transactions which I need to sum the "Units" by "Rate Code"  Resulting in Total Units per Rate Code.

 

Billing TransactionsBilling Transactions

 

2) Each "Rate Code" from the the billing transactions table is then related to a "Product Code" in the product catalog table.

ExRC table.JPG

 

3) A table of Taxes (Prod_Lvl_Exp_Rate) applies an amount of tax to each "Product Code" which is then related to the product catalog table.

 

Taxes TableTaxes Table

 

I need to come up with a way to multiply the tax, (Prod_Lvl_Exp_Rate), from the taxes table * the SUM of the "Units" of all related "Rate Codes" in the billing transactions table.

1 ACCEPTED SOLUTION

@drgrundy ,

 

Create a calculate column using dax as below:

Result =
VAR Current_Rate_Code = 'Billing Data'[Rate Code]
VAR Total_Units_per_Rate_Code =
    CALCULATE (
        SUM ( 'Billing Data'[Units] ),
        FILTER ( 'Billing Data', 'Billing Data'[Rate Code] = Current_Rate_Code )
    )
RETURN
    Total_Units_per_Rate_Code
        * CALCULATE (
            SUM ( 'Product Level Allocation Exp'[Prod_Lvl_Exp_Rate] ),
            FILTER (
                'Mod Expanded Rate Card',
                'Mod Expanded Rate Card'[Rate Code] = Current_Rate_Code
            )
        )

Community Support Team _ Jimmy Tao

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

View solution in original post

4 REPLIES 4
v-yuta-msft
Community Support
Community Support

@drgrundy ,

 

The expression is dependent on the relationship between the three tables, could you please show the relationship like "one-one", "one-many" between these tables?

 

Regards,

Jimmy Tao

Billing Transaction Table relationship to Rate Code Table is a Many : One relationship

Relation1.JPG

 

 

Taxes Table to Rate Code Table is a One : One relationship

Relation2.JPG

@drgrundy ,

 

Create a calculate column using dax as below:

Result =
VAR Current_Rate_Code = 'Billing Data'[Rate Code]
VAR Total_Units_per_Rate_Code =
    CALCULATE (
        SUM ( 'Billing Data'[Units] ),
        FILTER ( 'Billing Data', 'Billing Data'[Rate Code] = Current_Rate_Code )
    )
RETURN
    Total_Units_per_Rate_Code
        * CALCULATE (
            SUM ( 'Product Level Allocation Exp'[Prod_Lvl_Exp_Rate] ),
            FILTER (
                'Mod Expanded Rate Card',
                'Mod Expanded Rate Card'[Rate Code] = Current_Rate_Code
            )
        )

Community Support Team _ Jimmy Tao

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

Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Maybe RELATED or RELATEDTABLE?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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