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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
bvbuijs
Regular Visitor

Average based on distinct value in another column

Hi, 

 

I have a data set that looks like this:

 

CaseWorking hours betweenIn time? Y=1, N=0
1320
141
231
231
321
411
471
4210
541

 

And I need to report a total % of timeliness to a client. 

So I should get these % per case:

Case 1 = (0+1)/2 = 50%

Case 2 = (1+1)/2 = 100%

Case 3 = 100%

Case 4 = (1+1+0)/3 = 66.66%

Case 5 = 100%

 

So I should report: (50%+100%+100%+66.66%+100%)/5 = 83,332%

 

What is the best way to do this in PowerBI?

Thanks.

 

1 ACCEPTED SOLUTION

Hi @bvbuijs

 

You are missing parentheses,modify your measure as below:

Timeliness1_Percentage =
DIVIDE (
    SUMX (
        VALUES ( 'Cases Dump'[CaseNumber] ),
        DIVIDE (
            CALCULATE ( SUM ( 'Cases Dump'[Timeliness 1] ) ),
            CALCULATE ( COUNTROWS ( 'Cases Dump' ) )
        )
    ),
    COUNTROWS ( VALUES ( 'Cases Dump'[CaseNumber] ) )
)
 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

 

View solution in original post

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi @bvbuijs

 

Create 2 measures as below:

_percentage = 
var _sum=SUMX(FILTER(ALL('Table'),'Table'[Case]=MAX('Table'[Case])),'Table'[In time? Y=1, N=0])
var _count=CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Case]=MAX('Table'[Case])))
Return
DIVIDE(_sum,_count)
Measure 2 = 
var _table=SUMMARIZE('Table','Table'[Case],"_percentage",[_percentage])
var _sum=SUMX(_table,[_percentage])
var _count=CALCULATE(DISTINCTCOUNT('Table'[Case]),ALL('Table'))
Return
DIVIDE(_sum,_count)

And you will see:

Annotation 2020-08-11 105541.png

For the related .pbix file,pls see attached.

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

 

amitchandak
Super User
Super User

@bvbuijs , Try a new column

New Column = divide(sumx(filter(Table, [Case] = earlier([Case]) ),[ between In time]),countx(filter(Table, [Case] = earlier([Case]) ),[ between In time]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
parry2k
Super User
Super User

@bvbuijs try this measure

 

DIVIDE (
SUMX ( VALUES ( Table[Case] ), 
DIVIDE ( 
CALCULATE ( SUM ( Table[InTime] ),
CALCULATE ( COUNTROWS ( Table ) )
)
),
COUNTROWS ( VALUES ( Table[Case] ) )
)

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi,

 

@parry2k : I receive an error message when using this formula: "Too few arguments were passed to the DIVIDE function. The minimum argument count for the function is 2".  

 

 

My formula looks like this:

Timeliness1_Percentage = DIVIDE (SUMX ( VALUES ('Cases Dump'[CaseNumber]), DIVIDE (CALCULATE ( SUM ('Cases Dump'[Timeliness 1]), CALCULATE (COUNTROWS ('Cases Dump')))), COUNTROWS (VALUES ('Cases Dump'[CaseNumber]))))

 

How can I solve this?

Hi @bvbuijs

 

You are missing parentheses,modify your measure as below:

Timeliness1_Percentage =
DIVIDE (
    SUMX (
        VALUES ( 'Cases Dump'[CaseNumber] ),
        DIVIDE (
            CALCULATE ( SUM ( 'Cases Dump'[Timeliness 1] ) ),
            CALCULATE ( COUNTROWS ( 'Cases Dump' ) )
        )
    ),
    COUNTROWS ( VALUES ( 'Cases Dump'[CaseNumber] ) )
)
 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors