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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Neal369
New Member

Difference between measures - Based on Date Values

Hi Friends,

 

I am having below excel data, 

How can we calculate difference between total sales values with regrads to current date and previous date in table.

 

Neal369_0-1680318474322.png

 

I have calculated, Last Date as,

 

LastDate = CALCULATE(LASTDATE(Table1[ReportingDate]), FILTER(ALLSELECTED(Table1), Table1[ReportingDate] < MAX(Table1[ReportingDate])))
 
However, I am facing challange while calculating Total Sales corresponding to last date in order to calculate difference.
1 ACCEPTED SOLUTION
Walter_W2022
Resolver II
Resolver II

 

@Neal369 , the dates are not consecutive date, so you have to add index for the date table which extract from the fact table, so we can get the previous date sum, please see below screen shot, and also attached pbix file. the main measure is as below

_variance_preious_date =
VAR _lastDate = SELECTEDVALUE(dimDate[Index])-1
VAR _sumCurrent = CALCULATE(sum('fact'[Sales]))
VAR _sumLastDate = CALCULATE(sum('fact'[Sales]),dimDate[Index]=_lastDate,REMOVEFILTERS(dimDate))
VAR _value = IF(_lastDate = 0, _sumCurrent, _sumCurrent-_sumLastDate)
RETURN
_value
 

wangbt89_0-1680338016135.png

 

View solution in original post

1 REPLY 1
Walter_W2022
Resolver II
Resolver II

 

@Neal369 , the dates are not consecutive date, so you have to add index for the date table which extract from the fact table, so we can get the previous date sum, please see below screen shot, and also attached pbix file. the main measure is as below

_variance_preious_date =
VAR _lastDate = SELECTEDVALUE(dimDate[Index])-1
VAR _sumCurrent = CALCULATE(sum('fact'[Sales]))
VAR _sumLastDate = CALCULATE(sum('fact'[Sales]),dimDate[Index]=_lastDate,REMOVEFILTERS(dimDate))
VAR _value = IF(_lastDate = 0, _sumCurrent, _sumCurrent-_sumLastDate)
RETURN
_value
 

wangbt89_0-1680338016135.png

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.