Forum Discussion
powerbiAG
3 years agoFrequent Visitor
Calculation based on 2 measures across different months.
Hi All, We have a scenario where we need to do a calculation based on 2 measures across different months. Let me explain with example.. We have a monthly Sales table which has Actual Sales d...
- 3 years ago
Hi,
I do not know how your datamodel looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
It is for creating a measure.
Projected sales: = VAR _latestmonthdate = CALCULATE ( MAX ( Sales[Date] ), ALL ( 'Calendar' ) ) VAR _latestmonth = MAXX ( FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] = _latestmonthdate ), 'Calendar'[Month-Year] ) VAR _latestmonthsales = CALCULATE ( SUM ( Sales[Sales] ), FILTER ( ALL ( 'Calendar' ), 'Calendar'[Month-Year] = _latestmonth ) ) VAR _projectedbookings = MAX ( Projected[Projected bookings] ) RETURN IF ( ISBLANK ( SUM ( Sales[Sales] ) ), _latestmonthsales * _projectedbookings )
Jihwan_Kim
Super User
3 years agoHi,
I do not know how your datamodel looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
It is for creating a measure.
Projected sales: =
VAR _latestmonthdate =
CALCULATE ( MAX ( Sales[Date] ), ALL ( 'Calendar' ) )
VAR _latestmonth =
MAXX (
FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] = _latestmonthdate ),
'Calendar'[Month-Year]
)
VAR _latestmonthsales =
CALCULATE (
SUM ( Sales[Sales] ),
FILTER ( ALL ( 'Calendar' ), 'Calendar'[Month-Year] = _latestmonth )
)
VAR _projectedbookings =
MAX ( Projected[Projected bookings] )
RETURN
IF ( ISBLANK ( SUM ( Sales[Sales] ) ), _latestmonthsales * _projectedbookings )