Forum Discussion

FrankS72's avatar
FrankS72
Regular Visitor
6 years ago
Solved

Calculated Column

I'm struggling to performa required calc, which I want to do in a new column.

 

Example Data:

Table: Monthly_Sales   
     
ConsultantMonthSalesBest Month% Best
AdamAug 19 $      1,500 $          1,80083%
AdamSep 19 $      1,200 $          1,80067%
AdamOct 19 $      1,800 $          1,800100%
AdamNov 19 $      1,250 $          1,80069%
MandySep 19 $      3,500 $          4,00088%
MandyOct 19 $      3,250 $          4,00081%
MandyNov 19 $      4,000 $          4,000100%
SueNov 19 $      1,150 $          1,150100%
GeorgeAug 19 $      1,500 $          1,70088%
GeorgeSep 19 $      1,600 $          1,70094%
GeorgeOct 19 $      1,700 $          1,700100%

 

I want to calculate the 'best month' for each consultant (as a new column), and then compare each month to the best month at a row level.

I'm struggling to perform the best month calculation, as Maxx(Filter(..)) is returning the best month across all consultants, rather than for each.

 

Help will be greatly appreciated - I'm pretty new to Power BI 🙂

  • FrankS72 

     

    Try This:

     Best NEW = 
    
    VAR BEST = CALCULATE( MAX(SALES[Sales]),ALLEXCEPT(SALES,SALES[Consultant]))
    
    RETURN
    
    BEST
    
    

     

    % vs BEST = 
    
    DIVIDE(
        SALES[Sales],
        SALES[Best NEW]
    )

     

    ________________________

    Did I answer your question? Mark this post as a solution, this will help others!.

    I accept KUDOS 🙂

    YouTube, LinkedIn





5 Replies

  • FrankS72 

     

    Try This:

     Best NEW = 
    
    VAR BEST = CALCULATE( MAX(SALES[Sales]),ALLEXCEPT(SALES,SALES[Consultant]))
    
    RETURN
    
    BEST
    
    

     

    % vs BEST = 
    
    DIVIDE(
        SALES[Sales],
        SALES[Best NEW]
    )

     

    ________________________

    Did I answer your question? Mark this post as a solution, this will help others!.

    I accept KUDOS 🙂

    YouTube, LinkedIn





  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi FrankS72 ,

    You can create calculated columns or measures to achieve it:

    1. Create calculated columns

    Best Month = CALCULATE(MAX('Monthly_Sales'[Sales]),FILTER('Monthly_Sales','Monthly_Sales'[Consultant]=EARLIER('Monthly_Sales'[Consultant])))
    % Best = DIVIDE('Monthly_Sales'[Sales],'Monthly_Sales'[Best Month])

    2. Create measures

    Measure = CALCULATE(MAX('Monthly_Sales'[Sales]),FILTER(ALL('Monthly_Sales'),'Monthly_Sales'[Consultant]=MAX('Monthly_Sales'[Consultant])))
    Measure 2 = DIVIDE(MAX('Monthly_Sales'[Sales]),[Measure])

    Best Regards

    Rena