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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Joe_U
New Member

Sum values in a table based on criteria in a table not directly related

This should be simple, but I'm having a mental block.  I want to sum sales in the transaction table where the COUNT_ME field in the billing_Data table is equal to "Y"  .  Both tables have the CLIENT_ID and DATE field, but aren't directly joined.

Thanks in advance for any help.

Joe_U_0-1696885798931.png

 

 

4 REPLIES 4
Joe_U
New Member

Thank you for the quick response!  

I've been playing with your suggestion for the past hour plus and the result is still the entire sum of sales, not the filtered subset of sales.   I an only looking to sum sales in the transaction table where the coresponding records from the Billing_Data table based on DATE and Client_ID where COUNT_ME = "Y"

I'm not sure why I can't figure this out, it should be easy!

Any other suggestions are greatly appreciated.

 

Thank you

Anonymous
Not applicable

Hi @Joe_U ,

 

Here I create a sample to have a test.

Billing_Data:

vrzhoumsft_1-1697008505288.png

Transactions:

vrzhoumsft_0-1697008476596.png

Data model:

vrzhoumsft_2-1697008527356.png

Measure:

Sum Sales of Y =
VAR _ADD =
    ADDCOLUMNS (
        Transactions,
        "Count_Me",
            CALCULATE (
                MAX ( Billing_Data[COUNT_ME] ),
                FILTER (
                    Billing_Data,
                    Billing_Data[CLIENT_ID] = EARLIER ( [CLIENT_ID] )
                        && Billing_Data[DATE] = EARLIER ( [DATE] )
                )
            )
    )
RETURN
    SUMX ( FILTER ( _ADD, [Count_Me] = "Y" ), [Sales] )

Result is as below.

vrzhoumsft_3-1697008544815.png

 

Best Regards,
Rico Zhou

 

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

 

 

Thanks Rico, giving a try now!

vicky_
Super User
Super User

try something like:

 

Measure = 
var clientsFiltered = SELECTCOLUMNS(FILTER(Billing_data, Billing_data[COUNT_ME] = "Y"), "ClientID", Billing_data[Client_ID])

var transactions = CALCULATE(COUNT(Transactions[Client_ID]), TREATAS(clientsFiltered, Transactions[Client_ID]))

return transactions

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors