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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DhrubojitG
New Member

Sales YTD why one is working other is working

Power bi reference file download from drop Box 

Dear gurus ,

wrt the attached pbix link
Pls help me understand why  below measure is not working vs further below is working

Measure to compute sales YTD . .

 

 

Sales Amount YTD working = 
VAR LastVisibleDate = MAX ( 'Date'[Date] )
VAR CurrentYear = YEAR ( LastVisibleDate )
VAR SetOfDateesYtd =
    FILTER ( 
        ALL ( 'Date'), 
        AND ( 
            'Date'[Date] <= LastVisibleDate,
            YEAR ( 'Date'[Date] ) = CurrentYear
        )
    )
VAR Result =
    CALCULATE ( 
        SUMX ( Sales, Sales[Net Price]  * Sales[Quantity] ),
        SetOfDateesYtd 
    )
RETURN 
    Result

 

 

 but below is working

 

 

Sales Amount YTD working = 
VAR LastVisibleDate = MAX ( 'Date'[Date] )
VAR CurrentYear = YEAR ( LastVisibleDate )
VAR SetOfDateesYtd =
    FILTER ( 
        ALL ( 'Date'), 
        AND ( 
            'Date'[Date] <= LastVisibleDate,
            YEAR ( 'Date'[Date] ) = CurrentYear
        )
    )
VAR Result =
    CALCULATE ( 
        SUMX ( Sales, Sales[Net Price]  * Sales[Quantity] ),
        SetOfDateesYtd 
    )
RETURN 
    Result

 

 


After you look at the model you will shout at me that why the date table is linked via Date key but not the date which will fix the problem .
But that is not my point , my point is for learning , lets assume that model cant be changed and we are overcoming  in DAX layer

This is something related to claculate overriding the date filter in one versus other but I am not able to figure out point blank exactly.

I need a precise answer , I know that something to do with calculate overriding date filter . . but not able to figure it out exactly how .



1 ACCEPTED SOLUTION
Dangar332
Super User
Super User

Hi, @DhrubojitG 

in your first code you use   all('date') as a table refrence so you ignoring all filter of that table(date) means ignoring all filter coming from all columns of date table . you not ignoring filter from date[date] column so it override existing filter of another column(except date[date]) column. 

 

in second query you specify one column date[date] so it ignore only that column filter 

so you get stuck there and not getting proper answe 

 

read below artical for more information  article 1 , article 2 

and refer below video  video 1 

View solution in original post

1 REPLY 1
Dangar332
Super User
Super User

Hi, @DhrubojitG 

in your first code you use   all('date') as a table refrence so you ignoring all filter of that table(date) means ignoring all filter coming from all columns of date table . you not ignoring filter from date[date] column so it override existing filter of another column(except date[date]) column. 

 

in second query you specify one column date[date] so it ignore only that column filter 

so you get stuck there and not getting proper answe 

 

read below artical for more information  article 1 , article 2 

and refer below video  video 1 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.