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
ConnieMaldonado
Responsive Resident
Responsive Resident

Calculate distinct count for rows on table without slicer

I have a table that has revenue amounts by day, by technician. Each records has an associated Line of Business (LOB). I also have a date slicer and an org slicer.

 

RDO NameSite ManagerLocationLOB  Tech NameTechLoginStatusRevenueInvoice Date
RDO 1SM 1LOC 1LOB 1John Smith123456Active$902/5/21
RDO 1SM 1LOC 2LOB2John Smith123456Active$502/6/21
RDO 2SM 2LOC 1LOB1Sally Jones234567Active$752/10/21
RDO 2SM 1LOC 2LOB2Sally Jones234567Active$452/11/21

 

I need to calculate average weekly revenue by LOB during the timeframe selected in the date slicer.

I have this working beautifully, but I need to make a change, and I can't figure out how to do it.

To calculate the averages, I created measures for the following:

 

AVG NUMERATOR = Sum(RevenueByTech[Revenue])

 

Number of Distinct Techs =
CALCULATE (
DISTINCTCOUNT( RevenueByTech[TechLogin] ))

No of Weeks During Slicer Dates =
VAR _startDate = min( 'DATE Dim'[DATE] )
VAR _endDate = max( 'DATE Dim'[DATE] )
RETURN
AVERAGEX (
VALUES ( RevenueByTech[TechLogin] ),
DATEDIFF ( _startDate, _endDate, WEEK )
)

Average Weekly Revenue =
DIVIDE ( RevenueByTech[AVG NUMERATOR] , RevenueByTech[Number of Distinct Techs] * RevenueByTech[No of Weeks During Slicer Dates])

 

Using the above formula allowed the average calculation to change when different LOBs and orgs were selected from the slicer. The formula would only count the distinct techs that had revenue during the time period and based on the parameters selected in the other slicers (Org, LOB).

 

Now I need to use the same count of distinct techs for all LOBs in the average calculation. So I need to count the number of distinct techs during the slicer dates, and use that in the denominator. How do I calculate the number of distinct dates such that it doesn't change with the LOB selected?

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Revise the measures to

Number of Distinct Techs = CALCULATE(DISTINCTCOUNT(RevenueByTech[TechLogin]),all(RevenueByTech[lob]))

AVG NUMERATOR = calculate(Sum(RevenueByTech[Revenue]),all(RevenueByTech[lob]))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

1 REPLY 1
Ashish_Mathur
Super User
Super User

Hi,

Revise the measures to

Number of Distinct Techs = CALCULATE(DISTINCTCOUNT(RevenueByTech[TechLogin]),all(RevenueByTech[lob]))

AVG NUMERATOR = calculate(Sum(RevenueByTech[Revenue]),all(RevenueByTech[lob]))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.