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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
kpansia
Frequent Visitor

Trying to create buckets using a stacked column chart based on mail received.

Hey, I currently have a bar graph in power-bi. The graph has distinct id's on the x axis and the amount of mail they received on the y axis. In the Table I am using, I have SalesYear, id, and a Val column which has the value 1 in each row. The id shows up multiple times in the table, sometimes more than twice in the same year. The problem is I want the graph reversed. I would like to bucket people based on how much mail they received. Then use a slicer to see how much they receive per year. I have been struggling to find a solution on my own, would anyone have any ideas on how to approach this.
Table l looks like this:

id | salesYear | Val
10 |  2012      |  1
11 |  2012      | 1
11 |  2013      | 1
10 |  2012      | 1
10 |  2013      | 1
12 |  2012      | 1
12 |  2012      | 1
So in the visualization I want to show that on the x-axis that people who received 1 piece of mail = 0, 2 pieces of mail = 2, 3 pieces of mail = 1. My question is how can i achieve this will a Stacked Column chart. Any suggestions would be greatly appreciated!

1 ACCEPTED SOLUTION
Eric_Zhang
Microsoft Employee
Microsoft Employee


@kpansia wrote:

Hey, I currently have a bar graph in power-bi. The graph has distinct id's on the x axis and the amount of mail they received on the y axis. In the Table I am using, I have SalesYear, id, and a Val column which has the value 1 in each row. The id shows up multiple times in the table, sometimes more than twice in the same year. The problem is I want the graph reversed. I would like to bucket people based on how much mail they received. Then use a slicer to see how much they receive per year. I have been struggling to find a solution on my own, would anyone have any ideas on how to approach this.
Table l looks like this:

id | salesYear | Val
10 |  2012      |  1
11 |  2012      | 1
11 |  2013      | 1
10 |  2012      | 1
10 |  2013      | 1
12 |  2012      | 1
12 |  2012      | 1
So in the visualization I want to show that on the x-axis that people who received 1 piece of mail = 0, 2 pieces of mail = 2, 3 pieces of mail = 1. My question is how can i achieve this will a Stacked Column chart. Any suggestions would be greatly appreciated!


@kpansia

AFAIK, there's no too elegant solution, as a workaround, you can create an auxilary bucket table as below. See more details in the attached pbix file.

Capture.PNG

 

Then create a measure as

count =
VAR summarizedTbl =
    SUMMARIZE (
        'yourTable',
        'yourTable'[id],
        "mail pieces", SUM ( yourTable[Val] )
    )
VAR maiiPieces =
    COUNTROWS (
        FILTER (
            summarizedTbl,
            [mail pieces] > MAX ( buckets[lower] )
                && [mail pieces] <= MAX ( buckets[upper] )
        )
    )
RETURN
    IF ( ISBLANK ( maiiPieces ), 0, maiiPieces )

Capture.PNG

View solution in original post

1 REPLY 1
Eric_Zhang
Microsoft Employee
Microsoft Employee


@kpansia wrote:

Hey, I currently have a bar graph in power-bi. The graph has distinct id's on the x axis and the amount of mail they received on the y axis. In the Table I am using, I have SalesYear, id, and a Val column which has the value 1 in each row. The id shows up multiple times in the table, sometimes more than twice in the same year. The problem is I want the graph reversed. I would like to bucket people based on how much mail they received. Then use a slicer to see how much they receive per year. I have been struggling to find a solution on my own, would anyone have any ideas on how to approach this.
Table l looks like this:

id | salesYear | Val
10 |  2012      |  1
11 |  2012      | 1
11 |  2013      | 1
10 |  2012      | 1
10 |  2013      | 1
12 |  2012      | 1
12 |  2012      | 1
So in the visualization I want to show that on the x-axis that people who received 1 piece of mail = 0, 2 pieces of mail = 2, 3 pieces of mail = 1. My question is how can i achieve this will a Stacked Column chart. Any suggestions would be greatly appreciated!


@kpansia

AFAIK, there's no too elegant solution, as a workaround, you can create an auxilary bucket table as below. See more details in the attached pbix file.

Capture.PNG

 

Then create a measure as

count =
VAR summarizedTbl =
    SUMMARIZE (
        'yourTable',
        'yourTable'[id],
        "mail pieces", SUM ( yourTable[Val] )
    )
VAR maiiPieces =
    COUNTROWS (
        FILTER (
            summarizedTbl,
            [mail pieces] > MAX ( buckets[lower] )
                && [mail pieces] <= MAX ( buckets[upper] )
        )
    )
RETURN
    IF ( ISBLANK ( maiiPieces ), 0, maiiPieces )

Capture.PNG

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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