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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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