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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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