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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Create bins and use bin in bar chart

I have created a calculated column:
Category Sales Bin = (IF(Orders[Sale%]>0 && Orders[Sale%]<=0.06, "0% - 6%",
IF(Orders[Sale%]>0.06 && Orders[Sale%]<=0.14,"7% - 14%",
IF(Orders[Sale%]>0.14 && Orders[Sale%]<=0.21,"14% - 21%",
IF(Orders[Sale%]>0.21,"> 21%" )))))

sale% is also a calcualted column which is calculating percentage and is in decimal format.
Now Category Sales Bin is showing "0% - 6%" for all the values
For 13.01 or 12.68 it is showing "0% - 6%".

Why it is showing for all same value .

also i want to use this bin in bar chart and study sale% distribution bin wise

Power Bi File- Link 

 

 

2 ACCEPTED SOLUTIONS

Looking at the pbix, I think you already know the answer.  The Sales% in the table visual is an aggregation of the numeric column but the Category Sales Bin 3 is a text field which is not going to aggregate.

Sales% summed actually does make sense in the data but we have to be very careful adding up percentages normally.

 

One solution is to create SUM(sales%) as a measure and create the bucket calculation as a measure which refers to it.  I think you would have to use a variable to store the SUM(sales%) and then use that variable in the rest of the measure.  Don't overcomplicate it.

 

You will need Product SubCategory in the visual to provide the correct context 

 

Good luck.

 

 

View solution in original post

Icey
Community Support
Community Support

Hi @Anonymous ,

 

The cause is just like what @HotChilli said.

Please create a Measure like so:

Category Sales Bin =
VAR Sum_Sales =
    SUM ( Orders[Sale%] )
RETURN
     (
        IF (
            Sum_Sales > 0
                && Sum_Sales <= 0.06,
            "0% - 6%",
            IF (
                Sum_Sales > 0.06
                    && Sum_Sales <= 0.14,
                "7% - 14%",
                IF (
                    Sum_Sales > 0.14
                        && Sum_Sales <= 0.21,
                    "14% - 21%",
                    IF ( Sum_Sales > 0.21, "> 21%" )
                )
            )
        )
    )

 

 

Best Regards,

Icey

 

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

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Anonymous ,

 

The cause is just like what @HotChilli said.

Please create a Measure like so:

Category Sales Bin =
VAR Sum_Sales =
    SUM ( Orders[Sale%] )
RETURN
     (
        IF (
            Sum_Sales > 0
                && Sum_Sales <= 0.06,
            "0% - 6%",
            IF (
                Sum_Sales > 0.06
                    && Sum_Sales <= 0.14,
                "7% - 14%",
                IF (
                    Sum_Sales > 0.14
                        && Sum_Sales <= 0.21,
                    "14% - 21%",
                    IF ( Sum_Sales > 0.21, "> 21%" )
                )
            )
        )
    )

 

 

Best Regards,

Icey

 

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

amitchandak
Super User
Super User

@Anonymous , Please refer to my Video and the file attached after signature if those can help

https://www.youtube.com/watch?v=CuczXPj0N-k

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Looking at the pbix, I think you already know the answer.  The Sales% in the table visual is an aggregation of the numeric column but the Category Sales Bin 3 is a text field which is not going to aggregate.

Sales% summed actually does make sense in the data but we have to be very careful adding up percentages normally.

 

One solution is to create SUM(sales%) as a measure and create the bucket calculation as a measure which refers to it.  I think you would have to use a variable to store the SUM(sales%) and then use that variable in the rest of the measure.  Don't overcomplicate it.

 

You will need Product SubCategory in the visual to provide the correct context 

 

Good luck.

 

 

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.