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

DAX Help

I need help creating a DAX measure for the following task in the below dataset

YearMonthSales
2019Jan100
2019Feb110
2019Mar120
2019Apr130
2019May140
2019Jun150
2019Jul160
2019Aug170
2019Sep180
2019Oct190
2019Nov200
2019Dec210
2020Jan220
2020Feb230
2020Mar240
2020Apr250
2020May260

 

I need May 2020 sales as March 2020 + April 2020, April 2020 sales as March 2020. March 2020 sales needs to March 2019 to Feb 2020 (Sum of sales)

4 REPLIES 4
FrankAT
Community Champion
Community Champion

Hi @Anonymous 

take a look at the following solution:

 

05-10-_2020_16-01-25.png

 

Sum of Sales = SUM('Table'[Sales])


Running Total = 
CALCULATE(
    [Sum of Sales],
    FILTER(
        ALLEXCEPT('Table','Table'[Year]),
        'Table'[Date] <= MAX('Table'[Date])
    )
)

 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

amitchandak
Super User
Super User

@Anonymous , id every month logic is changing if need rolling you can do that with date table

2/3

 

Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-3,MONTH))
Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX(Sales[Sales Date]),-3,MONTH))
Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

 

Rolling 3 till last 1 month = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],Startofmonth(dateadd(Sales[Sales Date],-1,month)),3,MONTH))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

Anonymous
Not applicable

Amit, I am using the same logic to create 6 months rolling sums. But for YTD I am failing, I am wondering is there a way to create the same maybe as a calculated column? 

Hi, @Anonymous 

Could you please tell me whether your problem has been solved?
If yes, you could accept the helpful answer as solution. You also could share your own solution here. For now, there is no content of description in the thread. If you still need help, please share more details to us.

 

Best Regards,
Community Support Team _ Eason

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.