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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

calculatation day over day

Hi I need to calculate day over day

I attached the pbix file https://1drv.ms/u/s!Amd7BXzYs7AVhBBCo_Ls7q5IkrXH?e=d1nNmA 

 

I've tried the following calculated measure but actually it returns wrong values, it returns sales for current date, but I need to return sales for previous day. How to correct it?

sales day over day = var _maxdate=CALCULATE(max('Date'[Date]), ALLSELECTED('Date'[Date]))
var _mindate=CALCULATE(min('Date'[Date]), ALLSELECTED('Date'[Date]))
var dates=filter(values('Date'[Date]), 'Date'[Date]<=_maxdate && 'Date'[Date]>=_mindate)
return if(ISEMPTY('Date'), BLANK()
 
, calculate(sum(Sales[Sales]), FILTER(Sales, Sales[Date]<=_maxdate && Sales[Date] >=_mindate && PREVIOUSDAY('Date'[Date])))+0
)

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , With help from date table try measures like

 

This Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Last Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))
Last Day = CALCULATE(sum('Table'[Qty]), previousday('Date'[Date]))

 

diff =[This Day] - [Last Day]

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c3243d1f9

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

If we want to have data of selected period of Current Period and its corresponding previous period (eg. if we select [(02-02-2015 to 02-02-2016 the data of previous year 02-02-2014 to 02-02-2015 should display nearby graph in shadow mode)]

amitchandak
Super User
Super User

@Anonymous , With help from date table try measures like

 

This Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Last Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))
Last Day = CALCULATE(sum('Table'[Qty]), previousday('Date'[Date]))

 

diff =[This Day] - [Last Day]

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c3243d1f9

Anonymous
Not applicable

@amitchandak I should display 0 even if there's no data for all dates selected in the date range slicer, what you propose does not work. 

@Anonymous , if you add +0 to measure that should do .

 

One more solution for that for between date range

 

0 between range
Measure = var _1= SUM(Opportunity[Opportunity count]) +0
var _min = minx(ALLSELECTED('Calendar'), 'Calendar'[Date])
var _max = maxx(ALLSELECTED('Calendar'), 'Calendar'[Date])
return
CALCULATE(if(max('Calendar'[Date]) <_min || max('Calendar'[Date]) >_max , BLANK(), _1))

 

 

 

Sorry, Seem like did not get it completely

Anonymous
Not applicable

@amitchandak actually I add 0 but it doesn't work. Please check the pbix attached to my question. 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

August Carousel

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.