Forum Discussion
Differences between last 5 months
- Anonymous3 years ago
Hi @Theriaux ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create a measure as below:
Difference = VAR _seldate = SELECTEDVALUE ( 'Table'[Date] ) VAR _enddate = EOMONTH ( EDATE ( _seldate, -1 ), 0 ) VAR _startdate = EDATE ( _enddate, -5 ) + 1 VAR _pre5years = SUMX ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] >= _startdate && 'Table'[Date] <= _enddate ), [Total cases] ) RETURN IF ( ISBLANK ( _pre5years ), BLANK (), [Total cases] - _pre5years )You can refer the following links to get the values for last N months:
Display Last N months data in Power BI
Display Last N Months & Selected Month using Single Date Dimension in Power BI
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Hi @Theriaux ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want. You can create a measure as below:
Difference =
VAR _seldate =
SELECTEDVALUE ( 'Table'[Date] )
VAR _enddate =
EOMONTH ( EDATE ( _seldate, -1 ), 0 )
VAR _startdate =
EDATE ( _enddate, -5 ) + 1
VAR _pre5years =
SUMX (
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Date] >= _startdate
&& 'Table'[Date] <= _enddate
),
[Total cases]
)
RETURN
IF ( ISBLANK ( _pre5years ), BLANK (), [Total cases] - _pre5years )
You can refer the following links to get the values for last N months:
Display Last N months data in Power BI
Display Last N Months & Selected Month using Single Date Dimension in Power BI
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Hey Anonymous ,
thanks for your help. That is what I am looking for.
Cheers,
Shawn