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
nirrobi
Helper V
Helper V

Create measure % of total

Hi all,

 

I have table like the bellow.

I need to add measure name "import % of Total" that calculate for each row import / total total (50/483, ... 230/483 etc.)

How can you build this measure?

 

(Import is sum of column from one table

Export is sum of column from other table 

Total is the measure that sum import+export)

 

CustomerImportExportTotalImport % of Total
AAA505510510%
BBB606612612%
CCC707714714%
DDD505510510%
Total23025348348%

 

Many thanks.

 

Nir

1 ACCEPTED SOLUTION

Hey Nirrobi,

 

can you try this?

 

Import % of Total = var bigTotal = SUMX(ALL(Sheet1[Customer]), CALCULATE(SUM(Sheet1[Import]) + SUM(Sheet1[Export])))
                    return DIVIDE(SUM([Import]),bigTotal)

Basically

 

ALL(Sheet1[Customer])

Forces it to do the calculation across all your customers. 

 

CALCULATE(SUM(Sheet1[Import]) + SUM(Sheet1[Export])

Says to do the sum of Import and Export on a row by row basis i.e. the total

 

Wrapped with sumx it translates to, for all customers calculate the total on a row by row basis and then add together all the totals to get your Total of all totals.

 

Your % of total then just becomes:

 

DIVIDE(SUM([Import]),bigTotal)

This is the output that i get:

 

Capture.PNG

 

View solution in original post

11 REPLIES 11
Haegi
Advocate V
Advocate V

Hello,

 

First you can create an calculated column "BigTotal" = SUM(Total).

Calculated column don't work with context so it will be the sum of all rows of youre dataset.

 

Next you can create a new measure "Import ratio" = Import/BigTotal

 

Hope it's help you.

Thanks for your reply.

 

I did not manage to accomplish my task 😞

I manage to create one big table with my data and face similar problem to my opinion.

I need to have table/matrix like the one below but I cannot succeed to create the last column.

 

Hope someone can help.

 

Regards,

 

Cumm %% of totalAMOUNTCLIENT
17%17%100AAA
50%33%200BBB
100%50%300CCC
100%100%600TOTAL

I still struggle with this problem.

anyone? please...

@nirrobi did you try using what i had above? What are your problems now?

 

I tried and succeed many thanks.

 

can you pleaes help me with the below problem:

I need to create cumulative percentage in simple table.

 

 

Cumm %% of totalAMOUNTCLIENT
17%17%100AAA
50%33%200BBB
100%50%300CCC
100%100%600

TOTAL

Hello,

 

To calculate a cumulative percent.

You can use again to DAX formula to create a new measure.

 

I not sure but you can try a solution like this

Cumm = CALCULATE(SUM([%Total]), FILTER(ALL([Customer]), [%Total] <= 1))

Regards

Hi Nirrobi,

 

not sure where you got with this. I couldn't get exactly what you were looking for but this seems to be the best solution at the moment.

 

 

Import % Cumu* Total = var bigTotal = SUMX(ALL(Sheet1[CustID]), CALCULATE(SUM(Sheet1[Import])))
return DIVIDE(SUMX(FILTER(All(Sheet1[CustID]), Sheet1[CustID] <= MAX(Sheet1[CustID])),CALCULATE(SUM(Sheet1[Import]))),bigTotal)

 

You'll notice i had to use a customer Id which was an integer id representation of each customer. This is because the DAX <= operator cannot compare two strings. I thought sort by might be an option but the operator doesn't seem to call through to that.

 

This results with a table like below:

 

Capture.PNG

 

The first line of code:

 

var bigTotal = SUMX(ALL(Sheet1[CustID]), CALCULATE(SUM(Sheet1[Import])))

Like prior calculates the overall total.

 

 

The filter command in the second line:

 

FILTER(All(Sheet1[CustID]), Sheet1[CustID] <= MAX(Sheet1[CustID]))

Tells the calculation to only look at customer ids which less than the one you're currently looking at in the calculation.

 

 

Coupled with SUMX and then doing the division.

 

Let me know if that works.

 

Note if you want to use it in a table with the other measure created earlier you will need to create a measure based on that ID instead. 

Import % of Total CustID = var bigTotal = SUMX(ALL(Sheet1[CustID]), CALCULATE(SUM(Sheet1[Import]) + SUM(Sheet1[Export])))
                    return DIVIDE(SUM([Import]),bigTotal)

 

any one?

please...

 

 

Hey Nirrobi,

 

can you try this?

 

Import % of Total = var bigTotal = SUMX(ALL(Sheet1[Customer]), CALCULATE(SUM(Sheet1[Import]) + SUM(Sheet1[Export])))
                    return DIVIDE(SUM([Import]),bigTotal)

Basically

 

ALL(Sheet1[Customer])

Forces it to do the calculation across all your customers. 

 

CALCULATE(SUM(Sheet1[Import]) + SUM(Sheet1[Export])

Says to do the sum of Import and Export on a row by row basis i.e. the total

 

Wrapped with sumx it translates to, for all customers calculate the total on a row by row basis and then add together all the totals to get your Total of all totals.

 

Your % of total then just becomes:

 

DIVIDE(SUM([Import]),bigTotal)

This is the output that i get:

 

Capture.PNG

 

Can anyone help me?

 

I follow this but everytime my totals are 100%

 

Hi,

 

In which step you stucked?

 

never mind 🙂 here is summarize of this post:

 

I created the table as I mention in the first topic of this thread:

1.PNG

 

than I create a measure as follow:

Total ALL =
CALCULATE ( SUM ( Table1[Total] )ALL ( Table1 ) )

 

Measure Import % Of Total =
DIVIDE ( SUM ( Table1[Import] ), [Total ALL] )

 

Than with new feature call "quick measure" create the last measure:

Measure Import % Of Total running total in Customer =
CALCULATE (
    'Table1'[Measure Import % Of Total],
    FILTER (
        ALLSELECTED ( 'Table1'[Customer] ),
        ISONORAFTER ( 'Table1'[Customer], MAX ( 'Table1'[Customer] )DESC )

 

 

Hope it will help you.

 

Nir

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.