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
DeepDive
Helper IV
Helper IV

Total at Parent level and % share of total of parent.

Hi All,

 

Earlier post  Link

 

https://community.powerbi.com/t5/Desktop/Dynamic-Top-N-Categories-and-Top-N-Sub-Categories-and-Top-N...

 

In reference to my earlier question, I have further query related to same (sample data and PBI solution is there).

My issue here here is, now i need two new columns in one i need total of all cat/sub/brand at parent level irrespective to sum of  top one, and in second column i need  % share of top cat/sub/brand comparing it with the total of its parent.

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @DeepDive ,

If I got it correctly, you can try these steps:

1. Create a level table manually like this, use it as a slicer:

level tab.png

2. Create a first measure named [Total] for each level selected by the slicer:

Total =
IF (
    NOT ( ISFILTERED ( 'Level'[level] ) ),
    "Please select one level",
    IF (
        HASONEFILTER ( 'Level'[level] ),
        SWITCH (
            SELECTEDVALUE ( 'Level'[level] ),
            "Category", CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Category] ) ),
            "Sub Category",
                CALCULATE (
                    SUM ( 'Table'[Sales] ),
                    ALLEXCEPT ( 'Table', 'Table'[Sub Category] )
                ),
            "Brand", CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Brand] ) ),
            SUM ( 'Table'[Sales] )
        ),
        "Please just select one level"
    )
)

3. Create another measure named [share %] for each level selected by the slicer:

% share =
IF (
    NOT ( ISFILTERED ( 'Level'[level] ) ),
    "Please select one level",
    IF (
        HASONEFILTER ( 'Level'[level] ),
        VAR _Cat =
            CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Category] ) )
        VAR _Sub =
            CALCULATE (
                SUM ( 'Table'[Sales] ),
                ALLEXCEPT ( 'Table', 'Table'[Sub Category] )
            )
        VAR _Brand =
            CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Brand] ) )
        RETURN
            SWITCH (
                SELECTEDVALUE ( 'Level'[level] ),
                "Category", _Cat / _Cat,
                "Sub Category", _Sub / _Cat,
                "Brand", _Brand / _Cat
            ),
        "Please just select one level"
    )
)

4. Use a table visual to show the result dynamically by the level slicer:

level re.png

Attached the sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @DeepDive ,

If I got it correctly, you can try these steps:

1. Create a level table manually like this, use it as a slicer:

level tab.png

2. Create a first measure named [Total] for each level selected by the slicer:

Total =
IF (
    NOT ( ISFILTERED ( 'Level'[level] ) ),
    "Please select one level",
    IF (
        HASONEFILTER ( 'Level'[level] ),
        SWITCH (
            SELECTEDVALUE ( 'Level'[level] ),
            "Category", CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Category] ) ),
            "Sub Category",
                CALCULATE (
                    SUM ( 'Table'[Sales] ),
                    ALLEXCEPT ( 'Table', 'Table'[Sub Category] )
                ),
            "Brand", CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Brand] ) ),
            SUM ( 'Table'[Sales] )
        ),
        "Please just select one level"
    )
)

3. Create another measure named [share %] for each level selected by the slicer:

% share =
IF (
    NOT ( ISFILTERED ( 'Level'[level] ) ),
    "Please select one level",
    IF (
        HASONEFILTER ( 'Level'[level] ),
        VAR _Cat =
            CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Category] ) )
        VAR _Sub =
            CALCULATE (
                SUM ( 'Table'[Sales] ),
                ALLEXCEPT ( 'Table', 'Table'[Sub Category] )
            )
        VAR _Brand =
            CALCULATE ( SUM ( 'Table'[Sales] ), ALLEXCEPT ( 'Table', 'Table'[Brand] ) )
        RETURN
            SWITCH (
                SELECTEDVALUE ( 'Level'[level] ),
                "Category", _Cat / _Cat,
                "Sub Category", _Sub / _Cat,
                "Brand", _Brand / _Cat
            ),
        "Please just select one level"
    )
)

4. Use a table visual to show the result dynamically by the level slicer:

level re.png

Attached the sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

 

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.