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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
allauthors
Frequent Visitor

How to get an average row count for a grouping across multiple queries

I'm trying to figure out how to get the average row count per "item" for a particular status.  Hoping someone can help
Consider the following simplified example tables:

Items table

 ItemId   Status  
QA 
Done 
QA 
WIP 
QA 
WIP 

Done

 

PeoplesItems table

 Person   ItemId   Another Measurement  
Robert 
Robert 
Jenny 

 

I'm looking to produce a visualization which lists people and shows their Average number of times in QA per Item along with other calculations I've already figured out how to do.

 Person   QA's Per Item   Sum Another Measurement  
Robert 1.5 
Jenny 

 

Assuming that People to Item also has many other measurements that are also a part of the visualizaion

 

How do I create a measurement that will let me produce the result above for QA's Per Item.  Most of my DAX has been limited to counting rows where another column is a particular value.   I'm guessing there's some kind of DAX that can produce this average, but I'm stumped.  So if anyone can suggest the right DAX and the right table to put the measure on I'd be super appreciative.

 

I"m particularly keen for a solution that explains the "why" of the answer so that I can solve similar things in the future on my own.

1 ACCEPTED SOLUTION
v-xiandat-msft
Community Support
Community Support

Hi @allauthors ,

Below is my table1:

vxiandatmsft_0-1702523596099.png

Below is my table2:

vxiandatmsft_1-1702523618701.png

The following DAX might work for you:

Measure = 
   var iem = DISTINCTCOUNT('Table'[Itemid])
   var sta = 
   CALCULATE(
    COUNTROWS('Table'),
    FILTER('Table','Table'[Status]="QA" )
   )
    RETURN
      sta/iem

The final output is shown in the following figure:

vxiandatmsft_2-1702523660876.png

Best Regards,

Xianda Tang

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

1 REPLY 1
v-xiandat-msft
Community Support
Community Support

Hi @allauthors ,

Below is my table1:

vxiandatmsft_0-1702523596099.png

Below is my table2:

vxiandatmsft_1-1702523618701.png

The following DAX might work for you:

Measure = 
   var iem = DISTINCTCOUNT('Table'[Itemid])
   var sta = 
   CALCULATE(
    COUNTROWS('Table'),
    FILTER('Table','Table'[Status]="QA" )
   )
    RETURN
      sta/iem

The final output is shown in the following figure:

vxiandatmsft_2-1702523660876.png

Best Regards,

Xianda Tang

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

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.