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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
John117
New Member

Sum with filter and cross table

I have 2 tables, one with the date, customer name, and the gross sales and another table that is a selection of the most relevant customer by date, like this:

 

Table 1

DateCustomerGross Sales
01/06/2020X300
01/06/2020Y200
01/07/2020Y100
01/07/2020Z150

 

Table 2

DateCustomer
01/06/2020X
01/07/2020Y
01/07/2020X

 

I need to calculate the total sales of the most relevant customers, but it's not working. I'm using this formula:

 

Total gross = calculate(sum(Table1[Gross Sales]), filter(Table1, Table1[customer]=values(Table2[customer])))

 

The error message says 'MdxScript(Model) (4,102) Calculation error in measure: A table of multiple values was supplied where a single value was expected'

 

Could someone help me? I'm beginner in Power BI

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @John117 ,

 

VALUES() returns a single column table or a table of the same columns. In your scenario, VALUES(Table2[customer]) returns a table with a single column. Your problem is that a column cannot equal a table. You can use IN instead of “=”.


 

IN Creates a logical OR condition between each row being compared to a table. Note: the table constructor syntax uses curly braces. 'Product'[Color] IN { "Red", "Blue", "Black" }

 


The formula can be modified as follows:

 

Total gross 2 =
CALCULATE (
    SUM ( Table1[Gross Sales] ),
    FILTER ( Table1, Table1[customer] IN VALUES ( Table2[customer] ) )
)

 

The result is shown in the following figure:

sales.PNG

 

 

The above formula is limited to filtering customer names. If you also want to filter by date and customer name at the same time. You can write a calculated columns or a measure.

 

You can write your calculated column like so:

 

Total gross =
CALCULATE (
    SUM ( Table1[Gross Sales] ),
    FILTER (
        Table1,
        Table1[customer] = 'Table2'[customer]
            && Table1[Date] = Table2[Date]
    )
)

 

The result is shown in the following figure:

sales1.png

 

Or you can write your measure like so:

 

Total gross3 = 
VAR table3 =
    ADDCOLUMNS (
        Table2,
        "Total gross4", CALCULATE (
            SUM ( Table1[Gross Sales] ),
            FILTER (
                Table1,
                Table1[Customer] = Table2[customer]
                    && Table1[Date] = Table2[Date]
            )
        )
    )
RETURN
    SUMX ( table3, [Total gross4] )

 

 

The result is shown in the following figure:

sales2.png

 

You can check more details from here.

 

 

Best Regards,

Icey

 

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

3 REPLIES 3
Icey
Community Support
Community Support

Hi @John117 ,

 

VALUES() returns a single column table or a table of the same columns. In your scenario, VALUES(Table2[customer]) returns a table with a single column. Your problem is that a column cannot equal a table. You can use IN instead of “=”.


 

IN Creates a logical OR condition between each row being compared to a table. Note: the table constructor syntax uses curly braces. 'Product'[Color] IN { "Red", "Blue", "Black" }

 


The formula can be modified as follows:

 

Total gross 2 =
CALCULATE (
    SUM ( Table1[Gross Sales] ),
    FILTER ( Table1, Table1[customer] IN VALUES ( Table2[customer] ) )
)

 

The result is shown in the following figure:

sales.PNG

 

 

The above formula is limited to filtering customer names. If you also want to filter by date and customer name at the same time. You can write a calculated columns or a measure.

 

You can write your calculated column like so:

 

Total gross =
CALCULATE (
    SUM ( Table1[Gross Sales] ),
    FILTER (
        Table1,
        Table1[customer] = 'Table2'[customer]
            && Table1[Date] = Table2[Date]
    )
)

 

The result is shown in the following figure:

sales1.png

 

Or you can write your measure like so:

 

Total gross3 = 
VAR table3 =
    ADDCOLUMNS (
        Table2,
        "Total gross4", CALCULATE (
            SUM ( Table1[Gross Sales] ),
            FILTER (
                Table1,
                Table1[Customer] = Table2[customer]
                    && Table1[Date] = Table2[Date]
            )
        )
    )
RETURN
    SUMX ( table3, [Total gross4] )

 

 

The result is shown in the following figure:

sales2.png

 

You can check more details from here.

 

 

Best Regards,

Icey

 

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

Now it's working. Thank you so muck, @Icey !

 

lbendlin
Super User
Super User

Yes, VALUES() returns {X,Y}  from Table 2.  Don't you also want to filter by date? And correct your sample data in Table 2?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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