Forum Discussion
Find Previous Month Revenue
| Date | Revenue |
| 07/01/2022 12:00:00AM | 50000 |
| 08/01/2022 12:00:00AM | 75000 |
| 09/01/2022 12:00:00AM | 100000 |
I have to find max revenue and previous month (max of -1) Revenue and the DAX should be dynamic.
Help would be much appreciated..
- Anonymous3 years ago
Hi Anonymous ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want.
1. Create three measures as below:
Measure = SUM('Table'[Revenue])Max revenue = MAXX(ALLSELECTED('Table'),[Measure])Previous month (max of -1) Revenue = VAR _mrdate = CALCULATE ( MAX ( 'Table'[Date] ), FILTER ( ALLSELECTED ( 'Table' ), [Measure] = [Max revenue] ) ) VAR _predate = CALCULATE ( MAX ( 'Table'[Date] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] < _mrdate ) ) RETURN SUMX ( FILTER ( 'Table', 'Table'[Date] = _predate ), [Measure] )2. Create a card visual
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
1 Reply
- AnonymousNot applicable
Hi Anonymous ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want.
1. Create three measures as below:
Measure = SUM('Table'[Revenue])Max revenue = MAXX(ALLSELECTED('Table'),[Measure])Previous month (max of -1) Revenue = VAR _mrdate = CALCULATE ( MAX ( 'Table'[Date] ), FILTER ( ALLSELECTED ( 'Table' ), [Measure] = [Max revenue] ) ) VAR _predate = CALCULATE ( MAX ( 'Table'[Date] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] < _mrdate ) ) RETURN SUMX ( FILTER ( 'Table', 'Table'[Date] = _predate ), [Measure] )2. Create a card visual
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