Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Spend Buckets

Hi All,

 

I wanted to create spend buckets for spend by Name. However, I do not want to categorize the bucket by each line instead it will read total spend then it classifies which bucket it falls to. Also, I wanted to  use as column instead of measure so that I can display the buckets in chart.

 

Please refer my mock data below

 

This is what I wanted to display

 

Thank you!

  • Hi,

    Here is one way to do this:

    Bucket = var _sum = SUM('Table (32)'[Spend]) return

    SWITCH(TRUE(),
    _sum<50,"Less than 50",
    _sum<100,"More than 50",
    _sum>=100,"More than 100")

    When placed in a table the result is like this:

     

    If you want a column here is an example of that:

    Bucket_c = var _sum = CALCULATE(SUM('Table (32)'[Spend]),ALLEXCEPT('Table (32)','Table (32)'[Name])) return

    SWITCH(TRUE(),
    _sum<50,"Less than 50",
    _sum<100,"More than 50",
    _sum>=100,"More than 100")

     


    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/


3 Replies

  • ValtteriN's avatar
    ValtteriN
    Community Champion

    Hi,

    Here is one way to do this:

    Bucket = var _sum = SUM('Table (32)'[Spend]) return

    SWITCH(TRUE(),
    _sum<50,"Less than 50",
    _sum<100,"More than 50",
    _sum>=100,"More than 100")

    When placed in a table the result is like this:

     

    If you want a column here is an example of that:

    Bucket_c = var _sum = CALCULATE(SUM('Table (32)'[Spend]),ALLEXCEPT('Table (32)','Table (32)'[Name])) return

    SWITCH(TRUE(),
    _sum<50,"Less than 50",
    _sum<100,"More than 50",
    _sum>=100,"More than 100")

     


    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/


    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi ValtteriN ,

       

      That works like a charm! Thank you!

  • Hi Anonymous ,

     

    Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

     

    Refer to:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

     

    Best Regards,

    Jianbo Li

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