Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Stratifying into 1/3rds Formula

I have around 50 companies and their revenue amounts. I want to create a column or a measure (not sure which would be best) to stratify the revenue amounts into 1/3rds by largest to smallest in revenue. I want the top third (in total revenue amount) to get a risk score of 15, the middle third would get a 10 and the bottom third would get a 5. 

 

 

8 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Below is some sample data. So the file is two columns (Business and Revenue). 

      BusinessRevenue
      Cubs    344,748
      White Sox    193,262
      Red Sox      49,997
      Padres      45,929
      Yankees    155,912
      Dodgers      82,667
      Mets      79,192
      Cardinals      77,123
      Braves      74,897
      Astros      80,239
  • v-xuding-msft's avatar
    v-xuding-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

    I created a simple sample that you could try and check if it is what you want.

    They are all measures.

    Cumulated Revenue = 
    CALCULATE (
        SUM ( 'Table'[Revenue] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Business] <= MAX ( 'Table'[Business] ) )
    )
    
    Cumulated Percentage =
    DIVIDE (
        [Cumulated Revenue],
        CALCULATE ( SUM ( 'Table'[Revenue] ), ALL ( 'Table' ) )
    )
    
    ABC Class = 
    SWITCH (
        TRUE (),
        [Cumulated Percentage] <= 0.33,5,
        [Cumulated Percentage] <= 0.66,10,
       15
    )

    For more details, Please see the attchment. If I misunderstanding, you could reference the DAX patterns blog to have a try.

    ABC Classification 

     

    Best Regards,

    Xue Ding

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      After I made the cumulated Revenue measure I got the following error message:

       

      MdxScript(Model) (4,101) Calculation error in measure [Cumulated Revenue}: DAX comparison operations do not support comparing values of type Number with values of type Text.

      • v-xuding-msft's avatar
        v-xuding-msft
        Icon for Community Support rankCommunity Support

        Hi Anonymous ,

        > DAX comparison operations do not support comparing values of type Number with values of type Text.

        Based on the error message, it might be caused by the parentheses. You could use this to format it and check it. And can you please share your formula and the data type of columns? Then we can find the error out.

         

        Best Regards,

        Xue Ding

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