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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
gsandip
Frequent Visitor

How to show 'All' word as a dimension value in x axis for a bar chart?

Hi,

I have to show product categories in x axis and sum(sales) in Y axis as a measue.

 

But along with all product categories, I have to show 'All' as a categiry value in x axis, where all product sales will show.

Can it be achieved ?

 

1 ACCEPTED SOLUTION

Hi @gsandip ,

 

I had to change your sample data a bit so they can be split between 2022 and 2023.

First create a calculated table to get all the distinct values from Product Category then create a UNION with another table  that contains ALL.

Category = 
VAR __CATEGORY =
    ADDCOLUMNS ( SUMMARIZE ( 'Table', 'Table'[Product Category] ), "Sort", 1 )
VAR __ALL =
    ROW ( "Product Category", "ALL", "Sort", 0 )
RETURN
    UNION ( __CATEGORY, __ALL )

Sort column is added to custom sort Product Category by another column. ALL will be the first in the list. Make sure to custom sort.

 

Create the measure:

Sales Value by Product Category = 
IF (
    SELECTEDVALUE ( Category[Product Category] ) = "ALL",
    SUM ( 'Table'[Sales Value] ),
    CALCULATE (
        SUM ( 'Table'[Sales Value] ),
        FILTER (
            'Table',
            'Table'[Product Category] IN VALUES ( Category[Product Category] )
        )
    )
)

Sample result

danextian_0-1689430423360.png

 

Please see sample attached pbix

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

4 REPLIES 4
danextian
Super User
Super User

Hi @gsandip ,

 

It is achievable but not out of the box. You'll be needing a disconnected table that holds all product categories and another row for the word ALL and then a measure to return the value for each category + the value for ALL. Post a sample data so I can provide you with a sample pbix.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian,

Below is sample data:

IDSales ValueProduct CategoryReporting Date
112Cat120230731
213Cat220230731
314Cat220230731
416Cat120230630
567Cat120230630

 

Now I need to show 'Product Category' in X Axis and Sales = SUM(Sales Value)  measure in Y asix like below:

 

gsandip_2-1689412356002.png

 

 

Hi @gsandip ,

 

I had to change your sample data a bit so they can be split between 2022 and 2023.

First create a calculated table to get all the distinct values from Product Category then create a UNION with another table  that contains ALL.

Category = 
VAR __CATEGORY =
    ADDCOLUMNS ( SUMMARIZE ( 'Table', 'Table'[Product Category] ), "Sort", 1 )
VAR __ALL =
    ROW ( "Product Category", "ALL", "Sort", 0 )
RETURN
    UNION ( __CATEGORY, __ALL )

Sort column is added to custom sort Product Category by another column. ALL will be the first in the list. Make sure to custom sort.

 

Create the measure:

Sales Value by Product Category = 
IF (
    SELECTEDVALUE ( Category[Product Category] ) = "ALL",
    SUM ( 'Table'[Sales Value] ),
    CALCULATE (
        SUM ( 'Table'[Sales Value] ),
        FILTER (
            'Table',
            'Table'[Product Category] IN VALUES ( Category[Product Category] )
        )
    )
)

Sample result

danextian_0-1689430423360.png

 

Please see sample attached pbix

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi,

Can anybody help me on that?

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.