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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
carddosogabriel
Frequent Visitor

Data segmentation by month filter the values of the current month + the previous month from a SUMX

Good afternoon guys, how are you? I'm having a problem with a DAX function I've made:

First I made an Index that would return me 1 if a purchase had been made within a range of 8W:

1 - I8W = IF(

    CALCULATE(
        SUM('TABLE'[Net Sales Volume]),
            DATESINPERIOD('TABLE'[Data], MAX('TABLE'[Data]),-56,DAY)) > 0
    ,1
    ,0
)

carddosogabriel_0-1703354386864.png

 

The second formula sums I8W over the 8-week interval:

Sum_I8W = SUMX(ALL('DataBase'[SAP]), [I8W])
carddosogabriel_1-1703354884234.png

 

However, when I segment the data by month, the metric only returns the sum of the selected month, excluding the previous month.
carddosogabriel_2-1703355059720.png

I would like it to return August + July in the data segmentation when I check the August option, like this way without having to check the 2 boxes or when I select the month in a graph

carddosogabriel_3-1703355226855.png

Can anyone give me some help/insight with this?

Thank you very much and Merry Christmas to all! 🙂



1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Try this approach.

  1. Create a Calendar Table with calculated column formilas for Year, Month name and Month number.  Sort the Month name column by the Month number
  2. Create a relationship (Many to One and Single) from the Date column of Table to the Date column of the Calendar Table
  3. to your visual/slicer/filter, drag Date//Month name from the Calendar Table
  4. Write this measure

Measure = calculate(sum(table[Net sales volume]),datesbetween(calendar[date],max(calendar[date])-55,max(calendar[date])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
carddosogabriel
Frequent Visitor

It worked!!!!

@Ashish_Mathur, thank you so much!!! I've been thinking about this for days.

Can you tell me why? Why do we have this difference in Value with Dcalendario vs TableData?

Cheers, Merry Christmas!!!

carddosogabriel_0-1703426714391.png

 

You are welcome.  For any date calculation, creation of a Calendar Table is a must.  Creation of a Calendar Table, allows usage of the Date intelligence functions.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

Try this approach.

  1. Create a Calendar Table with calculated column formilas for Year, Month name and Month number.  Sort the Month name column by the Month number
  2. Create a relationship (Many to One and Single) from the Date column of Table to the Date column of the Calendar Table
  3. to your visual/slicer/filter, drag Date//Month name from the Calendar Table
  4. Write this measure

Measure = calculate(sum(table[Net sales volume]),datesbetween(calendar[date],max(calendar[date])-55,max(calendar[date])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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
Top Kudoed Authors