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
I_Like_Pi
Resolver II
Resolver II

Help with Percent of column total Measure

Hi: 

I am doing something called a benford analysis and would like to compare the results month over month.

I have a couple fields [Benf2] and [CycleDate].

I can build a nice cross tab of row counts on these 2 but they don't compare month over month very well unless I express them as a percentage of the column. Benf2 is the row, Cycle Date is the column.

I ended up with the following which works awesome except when it aggregates the total of all months.

M_Prct_Occurs = 
VAR
  CountofBenf = COUNTROWS(CAN_MonthlyTrans)
VAR
  CrntCycle = MAX(CAN_MonthlyTrans[Cycle Close Date])
RETURN   
  CALCULATE(CountofBenf / COUNTROWS(Filter(ALL(CAN_MonthlyTrans),CAN_MonthlyTrans[Cycle Close Date]=CrntCycle)))

 This returns the correct values in the cross tab for each of the "sub" columns but because I cheated by using the "MAX" formula to define my "CrntCycle" variable. My totals column is comparing the row counts of all Benf2's against the row count of just the last series. If that makes sense.

 

How should I have defined this so that my totals column works as well.

1 ACCEPTED SOLUTION
I_Like_Pi
Resolver II
Resolver II

I think I have solved it, and it was a bit easier than I expected. I defined a new measure that is supposed to do the same.

 

 

PercentALBFs = 
VAR
  CountofBenf = COUNTROWS(CAN_MonthlyTrans)
RETURN   
  CALCULATE(CountofBenf / COUNTROWS(CAN_MonthlyTrans),ALL(CAN_MonthlyTrans[Benf2]))

 

 

If I understand this correctly by not saying ALL in the Divisor, I retain the cycle close date filter of the current cycle close date column. Then saying ALL(CAN_MonthlyTrans[Benf2]) in the filter section removes the current row filter. The results appear to be correct. I will mark this as solved once I have confirmed a few more values.

View solution in original post

1 REPLY 1
I_Like_Pi
Resolver II
Resolver II

I think I have solved it, and it was a bit easier than I expected. I defined a new measure that is supposed to do the same.

 

 

PercentALBFs = 
VAR
  CountofBenf = COUNTROWS(CAN_MonthlyTrans)
RETURN   
  CALCULATE(CountofBenf / COUNTROWS(CAN_MonthlyTrans),ALL(CAN_MonthlyTrans[Benf2]))

 

 

If I understand this correctly by not saying ALL in the Divisor, I retain the cycle close date filter of the current cycle close date column. Then saying ALL(CAN_MonthlyTrans[Benf2]) in the filter section removes the current row filter. The results appear to be correct. I will mark this as solved once I have confirmed a few more values.

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.