Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
abeiswinger
Helper I
Helper I

Percentage of Total Metrics per Column (not Overall)

I would like the visual to take the total number of Inspections per month, add them, and show me the percentage (by month) of how many are on time.  When I use "show percentage" option, it shows overall instead of by month.  What kind of Measure formula can I use so that it calculates this for me?

 

My data with counts of Inspections:Inspection Percentages 1.png

What Power BI does:

Inspection Percentages 2.png

 

But I want it to say January = 79%, February =84%, etc.

January = 30/38

February = 38/45

etc.

 

If it helps... my spreadsheet/datasource is something like this:

Column A = Inspection number (unique identifier)
Column B = Date
Column C = On-Time or Past Target

3 ACCEPTED SOLUTIONS
Interkoubess
Solution Sage
Solution Sage

PastData.PNGPastData_.PNGHi @abeiswinger,

 

I reproduced you data and created this measure ( for details check pictures below):

 

Rat = DIVIDE(CALCULATE(SUM(TestData[OTT]),FILTER(TestData,TestData[Descr]="On Time")),CALCULATE(SUM(TestData[OTT])))

View solution in original post

v-caliao-msft
Employee
Employee

@abeiswinger,

 

Please refer to the steps below to acheive your requirement. 

  1. Sample data.
    Capture.PNG
  2. Create a masure by using DAX below.
    Measure = CALCULATE(SUM(Table1[InspectionNumber]),FILTER(ALLEXCEPT(Table1,Table1[Month]),Table1[Type2]="On-Time"))/CALCULATE(SUM(Table1[InspectionNumber]),ALLEXCEPT(Table1,Table1[Month]))
  3. User this measure in your visual.
    Capture1.PNG

Regards,

Charlie Liao

View solution in original post

8 REPLIES 8
v-caliao-msft
Employee
Employee

@abeiswinger,

 

Please refer to the steps below to acheive your requirement. 

  1. Sample data.
    Capture.PNG
  2. Create a masure by using DAX below.
    Measure = CALCULATE(SUM(Table1[InspectionNumber]),FILTER(ALLEXCEPT(Table1,Table1[Month]),Table1[Type2]="On-Time"))/CALCULATE(SUM(Table1[InspectionNumber]),ALLEXCEPT(Table1,Table1[Month]))
  3. User this measure in your visual.
    Capture1.PNG

Regards,

Charlie Liao

@v-caliao-msft

 

So close!  For some reason all my data now displays as the same?? Screenshot below of what it looks like with the measure, as well as what I have in my Visualizations... how can this be corrected?  My January data should be 79% and February should be 84%, etc...

 

2017-08-22_11-06-45.png2017-08-22_11-06-17.png

Interkoubess
Solution Sage
Solution Sage

PastData.PNGPastData_.PNGHi @abeiswinger,

 

I reproduced you data and created this measure ( for details check pictures below):

 

Rat = DIVIDE(CALCULATE(SUM(TestData[OTT]),FILTER(TestData,TestData[Descr]="On Time")),CALCULATE(SUM(TestData[OTT])))

@Interkoubess

 

Sorry, this formula is not working for me.  Can you please explain what each value is supposed to be?  I'm not sure where data is being pulled from:

 

Rat = DIVIDE(CALCULATE(SUM(TestData[OTT]),FILTER(TestData,TestData[Descr]="On Time")),CALCULATE(SUM(TestData[OTT])))

 

I'm assuming that anything that says [TestData[OTT] = the name of the tab (from Excel datasource) and the title of the column that I want to pull the "On-Time" or "Past Target" from?


So in the red, and blue, and green text... I change to mine.  However, what should I input for the blue bold text?  if I only put the tab name, I recieve an error message: MdxScript(Model) (3,46) Calculation error in measure 'WO Detail'[RAT]: The function SUM cannot work with the values of type String.

 

WO Detail is the name of my tab.

 

Hi @abeiswinger,

 

You are trying to sum up a string value.

 

'WO Detail'[RAT]: The function SUM cannot work with the values of type String.

 

Please change the type of data for example to Whole number or Decimal ones, etc...

From what you told me, the formula will be :

 

Rat = DIVIDE(CALCULATE(SUM('WO Detail'[RAT]:),FILTER('WO Detail','WO Detail'[the field you have on time]="On Time")),CALCULATE(SUM('WO Detail'[RAT])))

 

 

Furthermore a sample could help if you cannot apply this formula to your model.

 

Please dont hesitate if I can help.

 

Thx, Ninter

@Interkoubess

 

 What do you mean by "Please change the type of data for example to Whole number or Decimal ones, etc..."

Do I leave the [RAT] in the formula, or should that be changed as well?

 

Thanks

Hi @abeiswinger.

 

Your column named RAT is a string ( for example your name and surname you cannot add them as a sum).

And this is whqt you qre trying to do.

Select the column is PowerQuery for example and change the data type.

 

Let us know.

 

Thanks

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.