Forum Discussion
Rana
10 years agoRegular Visitor
Difference between 2 columns
I have a Matrix in PowerBI which is showing data for 2 months (month is a string not a date column like Aug, Sept or any selected 2 months). Matrix shows me Total for both months, instead of Sum i ne...
- 10 years ago
@Rana,
A much cleaner code than the one posted by me before (and deleted) is the following:
PreviousDay = CALCULATE ( SUM (FactData[Employees]); Filter (ALL(FactData[Date]);FactData[Date]=Max(FactData[Date])-1) ) Difference = IF( ISBLANK([PreviousDay]); 0; SUM(FactData[Employees])-[PreviousDay] )
leonardmurphy
10 years agoSkilled Sharer
No, a Matrix couldn't work with a subtraction formula in place of the totals.
How would the matrix know whether you want to subtract Aug from Sep vs. Sep from Aug (given the months are strings)? What would you want to happen if a person picks 3 or more months instead of just 2?
A measure would probably be your way forward. You could create a measure that subtracts a previous month value for any given month. But it wouldn't work dynamically with any two random months.