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
Ranahazim
Frequent Visitor

advanced and costomized percent measures

the percent is a result to a measure, the problem that it calculates a percent of each group. i want the percent to be from the totals of each row on the rightthe percent is a result to a measure, the problem that it calculates a percent of each group. i want the percent to be from the totals of each row on the right

like the 6.1% is calculated from the 570000 whereas i need it from the 1920000

any tricks? the filters in measure didnt work in this case

thanks 

1 ACCEPTED SOLUTION

hi, @Ranahazim

for the measure 2, It requires a specific data structure, this measure is just for my data structure,

so please share your simple sample pbix file.

for calculate the 38% percentage. of the P among age *1* and similar for each age groups

you may try to use these two measures as below:

Measure 11 = CALCULATE(SUM(Table2[current balance]),Table2[type]="P")/CALCULATE(SUM(Table2[current balance]),ALLEXCEPT(Table2,Table2[age]))

or

Measure 12 = CALCULATE(SUM(Table2[current balance]),FILTER(Table2,Table2[type]="P"))/CALCULATE(SUM(Table2[current balance]),ALLEXCEPT(Table2,Table2[age]))

Result:

14.PNG

Best Regards,

Lin

 

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

5 REPLIES 5
v-lili6-msft
Community Support
Community Support

hi, @Ranahazim

    It involves the row context and filter context in Dax, the measure in the table is calculated for the current row,

but total is the measure calculated for the whole table.

for example:

Assume that we have a basic table like this 

12.PNG

then we add a measure to calculate the percent that Qty of type is B in total Qty

Measure = CALCULATE(SUM(Table1[Qty]),Table1[Type]="B")/CALCULATE(SUM(Table1[Qty]))

then get the result

13.PNG

for periode 1 measure=5/15=33%  ,periode 2 measure=5/25=20%

but the total is (5+5)/160=6%

If you want to get the total is 53%

you need to add a further measure like this:

Measure 2 = 
var _Table = ADDCOLUMNS(SUMMARIZE(Table1,Table1[Periode],"Q",CALCULATE(SUM(Table1[Qty]))),"PER",CALCULATE(SUM(Table1[Qty]),Table1[Type]="B")/CALCULATE(SUM(Table1[Qty]))) return
CALCULATE(SUMX(_Table,[Measure]))

Result:

14.PNG

 

If it is not your case, please share pbix file or some data sample and expected output. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading.

 

 

Best Regards,

Lin

 

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

Hi Again @v-lili6-msft 

your first measure worked out and thank you alot 

i tried also the second because i need both ratios but i kept getting the same as the first measure 

your measure was: Measure 2 = var _Table = ADDCOLUMNS(SUMMARIZE(Table1,Table1[Periode],"Q",CALCULATE(SUM(Table1[Qty]))),"PER",CALCULATE(SUM(Table1[Qty]),Table1[Type]="B")/CALCULATE(SUM(Table1[Qty]))) return CALCULATE(SUMX(_Table,[Measure]))

and i applied it as Measure 2 = VAR _table = (ADDCOLUMNS(SUMMARIZE('EVS Account','EVS Account'[Periode],"M",CALCULATE(SUM('EVS Account'[Credit_Limit]))),"PER",CALCULATE(SUM('EVS Account'[Credit_Limit]),'EVS Account'[Action_Code]="P")/CALCULATE(SUM('EVS Account'[Credit_Limit])))) Return CALCULATE(SUMX(_table,[Prosent of Pastdue konto benyttet kredit])) could u pls look at it? 

 

in measure2: i wanted the percent of a group called P of each from (  2,....12) which is loan age among all the group in each month period (Periode) which is in your excample in your previous answer : i want all the "B" percent to all other letters in each periode 1 or 2 . 

 

I appreciate alot the help 

best regards 

Rana 

 

the fisrt percentage is perfectthe fisrt percentage is perfect 

In the table below . as excample of my data. the goal is to calculate the 38% percentage. of the P among age *1* and similar for each age groups 

 

I appreciate alot the help 

best regards 

Rana 

 

agecurrent balancetype
1500 
1300P
2500P
3600 
4200P
   
 2100 
   
 300/(300+500) 38%

hi, @Ranahazim

for the measure 2, It requires a specific data structure, this measure is just for my data structure,

so please share your simple sample pbix file.

for calculate the 38% percentage. of the P among age *1* and similar for each age groups

you may try to use these two measures as below:

Measure 11 = CALCULATE(SUM(Table2[current balance]),Table2[type]="P")/CALCULATE(SUM(Table2[current balance]),ALLEXCEPT(Table2,Table2[age]))

or

Measure 12 = CALCULATE(SUM(Table2[current balance]),FILTER(Table2,Table2[type]="P"))/CALCULATE(SUM(Table2[current balance]),ALLEXCEPT(Table2,Table2[age]))

Result:

14.PNG

Best Regards,

Lin

 

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

Thanks alot v-lili6-msft

 

Greg_Deckler
Super User
Super User

Would need to understand the source data. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.