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
Anonymous
Not applicable

Simple SUM filter problem driving me crazy

Dear power friends, 

 

I have a regular monthly CALENDAR_TABLE with the typical content

DATE
01/01/2018
02/01/2018
03/01/2018
(...)

linked to a SALES_TABLES by a date column in the same format (MM / 01/2018)
I need to sum the sales for only the last month of the selected date range. For example: if I select 01/01/2018 - 03/01/2018,  I will get the sum of sales only for month 03.

 

I've tryed:

 

1) create a measure called dMaxDateCalendar = LASTDATE(CALENDAR_TABLE[date])

 

and

2) the following measure

 

CALCULATE (
         SUM (SALES_TABLES [sales]);
         FILTER (SALES_TABLE;
                          SALES_TABLES[data] = [dMaxDateCalendar])
         )

 

But it returned de sum of all date range

 

than I've tryed:

 

3) SUMX(FILTER(SALES_TABLE;

SALES_TABLE[date]=[dMaxDataCalendario]);

SALES_TABLES [sales])

 

 but it returned, again, de sum of all date range.

 

What am I doing wrong?

 

Thanks,

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may use Variables in DAX.

Measure =
VAR d =
    LASTDATE ( CALENDAR_TABLE[date] )
RETURN
    CALCULATE (
        SUM ( SALES_TABLE[sales] ),
        FILTER ( SALES_TABLE, SALES_TABLE[date] = d )
    )

 

Community Support Team _ Sam Zha
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

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may use Variables in DAX.

Measure =
VAR d =
    LASTDATE ( CALENDAR_TABLE[date] )
RETURN
    CALCULATE (
        SUM ( SALES_TABLE[sales] ),
        FILTER ( SALES_TABLE, SALES_TABLE[date] = d )
    )

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

You're right, @v-chuncz-msft.

Thanks for you time, Sam.

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.