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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lsullivan6311
Helper III
Helper III

Customer Max Month sales volume on current year and Customer Max Month sales volume on prior year

Here is an example:

 

2021

Month       SalesVol

01 (Jan)     100

02 (Feb)     10

03(Mar)        5

04(Apr)         1

05(May)         2

06(Jun)          7

07(Jul)           25

08(Aug)         153

09(Sep)          29

10(Oct)          45

11(Nov)         125

12(Dec)          150

 

The max for this year is 153.

 

I need a max measure for current year

and one for prior year.

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Share data in a proper format (which can be pasted to an MS Excel file) or share the download link of the PBI file.  Also, is there no year column?  Is there no Date column?  How does one differenciate between 2 years of data?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
v-rzhou-msft
Community Support
Community Support

Hi @lsullivan6311 ,

 

I agree with Ashish_Mathur, I think your table should contain Years. My sample table is as below.

RicoZhou_0-1650335801086.png

Measure:

MaxSale Current Year = CALCULATE(MAX('Table'[SalesVol]),FILTER(ALL('Table'),'Table'[Year] = YEAR(NOW())))
MaxSale Previous Year = CALCULATE(MAX('Table'[SalesVol]),FILTER(ALL('Table'),'Table'[Year] = YEAR(NOW())-1))

Result is as below.

RicoZhou_1-1650336043318.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes, I did have year in my table, and this formula gave me the max for the current year and the previous year.  Is there a way if I have a group I would like to have the max by year that I could aggregate that way?  For example, for sales regions, so that I have a max year sales by each sales region?  Right now, it just puts in the max for every sales region.  The sales region is included in my table.

Hi @lsullivan6311 ,

 

I think you can try this code to calculate the max sales for each year and each Sales Region.

MaxSale each Year each Sales Region =
CALCULATE (
    MAX ( 'Table'[SalesVol] ),
    ALLEXCEPT ( 'Table', 'Table'[Year], 'Table'[Sales Region] )
)

Result is as below.

RicoZhou_0-1650423501412.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

This worked and I am able to get the max sales by region by year; however, now I am asked to provide a column in the Matrix for a difference in max from one year to another, say from 2020 to 2021, and another column with the % of 2021 to 2020.  Is this possible?  So, my Matrix would look like:

 

Sales Region       2020 Max Sales   2021 Max Sales    Increase/Decrease        % 2021/2020

        A                      100                        90                           -10                             90%

        B                       250                      275                            25                           110%  

        C                         5                          25                            20                           500%

Ashish_Mathur
Super User
Super User

Share data in a proper format (which can be pasted to an MS Excel file) or share the download link of the PBI file.  Also, is there no year column?  Is there no Date column?  How does one differenciate between 2 years of data?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.