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

stop running total if today-1 DAX

Hi, 

 

i need some help in understanding why my dax measure only returns blank rows for my rolling total as soon as i add my clause to stop if Period[DATE]= TODAY()-1

 

my tables are joined on Period[Datekey] = Sales[DimDatekey]

 

This returns a correct running total but includes ofcourse days which have no sales since it goes further than my last sale date. 

 

Rolling 7 days =
CALCULATE([Sales Volume],DATESINPERIOD(Period[Date],LASTDATE(Period[Date]),-7,DAY))
 
As soon as i add this, all rows blanks out and returns 0. Im probably doing something wrong but i cant get my head around it. 
 
2 Rolling 7 days =
IF(
SELECTEDVALUE(Period[Date])=TODAY()-1,
CALCULATE([Sales Volume],DATESINPERIOD(Period[Date],LASTDATE(Period[Date]),-7,DAY))
)

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Reaper1337 , Test as

Rolling 7 days ? CALCULATE(sum(Sal[Sales Amount]),DATESINPERIOD('Date'[Date],max(Sales[Sales Date]),-7,Day))

O

Rolling 7 days ? CALCULATE(sum(Sal[Sales Amount]),DATESINPERIOD('Date'[Date],max(Sales[Sales Date])-1 ,-7,Day))

O

Rolling 7 days ? CALCULATE(sum(Sal[Sales Amount]),DATESINPERIOD('Date'[Date],max('Date'[Date]),-7,Day))

Rolling 7 days ? CALCULATE(sum(Sal[Sales Amount]),DATESINPERIOD('Date'[Date],max('Date'[Date]) -1 ,-7,Day))

To get the best out of the time intelligence function. Make sure that you have a date calendar and that it has been marked as the date in the model view. Also, join her with the date column of your events. See :radacad sqlbi My Video Series Appreciate your congratulations.

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Reaper1337 , Test as

Rolling 7 days ? CALCULATE(sum(Sal[Sales Amount]),DATESINPERIOD('Date'[Date],max(Sales[Sales Date]),-7,Day))

O

Rolling 7 days ? CALCULATE(sum(Sal[Sales Amount]),DATESINPERIOD('Date'[Date],max(Sales[Sales Date])-1 ,-7,Day))

O

Rolling 7 days ? CALCULATE(sum(Sal[Sales Amount]),DATESINPERIOD('Date'[Date],max('Date'[Date]),-7,Day))

Rolling 7 days ? CALCULATE(sum(Sal[Sales Amount]),DATESINPERIOD('Date'[Date],max('Date'[Date]) -1 ,-7,Day))

To get the best out of the time intelligence function. Make sure that you have a date calendar and that it has been marked as the date in the model view. Also, join her with the date column of your events. See :radacad sqlbi My Video Series Appreciate your congratulations.

Fowmy
Super User
Super User

@Anonymous 

Can you try the following measure

 

IF(
isblank([Sales Volume]), blank(),
CALCULATE([Sales Volume],DATESINPERIOD(Period[Date],max(Period[Date])-1,-7,DAY))
)

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.