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
MaleneL
Helper II
Helper II

calculate the percentage size of partial subset DAX

Hi all 
I am working with at dataset, where we need to calculate a Report Measuer that calculate the percentage size for only some of the category, en excel it would look like this (we do not want 3. privat to be part of the procentage for the rest):

 

MaleneL_0-1697016352102.png

here is some data that can be used as an excempel

 

FT_branche_niv2Amount
2.1 Landbrug, jagt og skovbrug og fiskeri182076394
2.2 Industri og råstofindvinding18784097
2.3 Energiforsyning10081600
2.4.1 Gennemførelse af byggeprojekter2878331
2.4.2 Opførelse af bygninger2896211
2.4.3 Bygge og anlæg i øvrigt9469046
2.5 Handel23195879
2.6.1 Transport, post- og kurertjenester8747250
2.6.2 Hoteller og restauranter5572916
2.7 Information og kommunikation13103419
2.8 Finansiering og forsikring30235439
2.9.2 Udlejning mv. af fast ejendom45626339
2.9.3 Ejendomsmæglere og ejendomsadministration4458115
2.10 Administrative og support services5838250
2.10 Andre serviceydelser844451
2.10 Børnehaver23566507
2.10 Foreninger og organisationer39182434
2.10 Kultur og Fritid29687015
2.10 Offentlig forvaltning og forsvar5555
2.10 Prof, videnskabelig og tekniske services41265004
2.10 Sociale Institutioner77646136
2.10 Sundhedsvæsen11812738
2.10 Undervisning146340663
3. Privat1313260033

Any suggestion?

 

 

 

1 ACCEPTED SOLUTION

Hi @MaleneL ,

I updated the sample pbix file(see the attachment), please find the details in it.

Measure = 
VAR _tab =
    ADDCOLUMNS (
        'Table',
        "@categoryset",
            VAR _posi =
                IFERROR ( SEARCH ( ".", 'Table'[Category], 1, 0 ), 0 )
            RETURN
                LEFT ( 'Table'[Category], _posi - 1 )
    )
RETURN
    DIVIDE (
        SUM ( 'Table'[Sum of Amount] ),
        CALCULATE (
            SUM ( 'Table'[Sum of Amount] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                LEFT (
                    'Table'[Category],
                    IFERROR ( SEARCH ( ".", 'Table'[Category], 1, 0 ), 0 ) - 1
                )
                    = MAXX ( _tab, [@categoryset] )
            )
        )
    )

vyiruanmsft_0-1698309493854.png

Best Regards

Community Support Team _ Rena
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

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @MaleneL ,

I created a sample pbix file(see the attachment),please check if that is what you want. You can create two calculated column as below to get it:

Category Set = 
VAR _posi =
    IFERROR ( SEARCH ( ".", 'Table'[Category], 1, 0 ), 0 )
RETURN
    LEFT ( 'Table'[Category], _posi - 1 )
% in category = 
DIVIDE (
    [Sum of Amount],
    CALCULATE (
        SUM ( 'Table'[Sum of Amount] ),
        FILTER ( 'Table', 'Table'[Category Set] = EARLIER ( 'Table'[Category Set] ) )
    )
)

vyiruanmsft_0-1697531721113.png

Best Regards

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

Hi Rena

thanks for your solution. 

I can see that I have not been correct in exact enough. I need it as at Report Measure and not part of my dataset as you have shown 
But thanks for your help 🙏

Hi @MaleneL ,

I updated the sample pbix file(see the attachment), please find the details in it.

Measure = 
VAR _tab =
    ADDCOLUMNS (
        'Table',
        "@categoryset",
            VAR _posi =
                IFERROR ( SEARCH ( ".", 'Table'[Category], 1, 0 ), 0 )
            RETURN
                LEFT ( 'Table'[Category], _posi - 1 )
    )
RETURN
    DIVIDE (
        SUM ( 'Table'[Sum of Amount] ),
        CALCULATE (
            SUM ( 'Table'[Sum of Amount] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                LEFT (
                    'Table'[Category],
                    IFERROR ( SEARCH ( ".", 'Table'[Category], 1, 0 ), 0 ) - 1
                )
                    = MAXX ( _tab, [@categoryset] )
            )
        )
    )

vyiruanmsft_0-1698309493854.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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.