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
gvg
Post Prodigy
Post Prodigy

Can't figure out what is wrong with the filter

Hi,

 

I have this measure and can't really figure out, why is it not working. I get error "A table of multiple values was supplied were a single value was expected". 

 

Sum Sales  =
    CALCULATE (
        SUM ( Sales[Amount] ),
        FILTER (
            ALL ( 'Date' ),
            DATESBETWEEN ( 'Date'[Date], DATE (2017,1,1), DATE(2017,9,30) )
        )
    )
4 REPLIES 4

Try this

 

Sum Sales  =
    CALCULATE (
        SUM ( Sales[Amount] ),    
            DATESBETWEEN ( 'Date'[Date], DATE (2017,1,1), DATE(2017,9,30) 
    )


* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

OK. But how come this works and FILTER doesn't? Doesn't your CALCULATE translates internally to my CALCULATE with FILTER ?

 


@gvg wrote:

OK. But how come this works and FILTER doesn't? Doesn't your CALCULATE translates internally to my CALCULATE with FILTER ?


CALCULATE has 2 syntaxes

Simple syntax - this is what you are describing where the simple syntax is converted to the full syntax you mentioned.

Advanced (or table) syntax - this is what my formula does - it takes a table as a filter to CALCULATE.  DATESBETWEEN returns a table of dates. Whenever you get a table, you must use it directly in CALCULATE (advanced syntax). 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Advanced (or table) syntax 


 

OK. But doesn't FILTER return a table as well?

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.