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
Surendra_thota
Helper II
Helper II

DAX Distinct count of weekend from selected Input dates

HI All

 

we have a requirement . when a user give the range of dates the out put should be as below on week basis , PowerBIAvg1.PNG

 

In the above example fact table have data only in 2nd week , the 1st week is not having any data , still we need to show with zeros above , the problem here is we have to create average for those 2 weeks .

 

 

so to create average  we tried like this 

 

AvgSum = CALCULATE(sumx(View_Compliance,View_Compliance[Compliance %]),ALLSELECTED('Date'[Week Ending]))

Avgcount = CALCULATE(Distinctcount([Week Ending]),ALLSELECTED('Date'[Week Ending]))

 

The avg sum is getting correct , but avg count of weeks we are getting only 1 , we should get 2 in ooour case  but it is giving only 1 as we have data for only 1 week.

 

i have tried 

AvgCount_1 = CALCULATE(Distinctcount('Date'[Week Ending]), DATESBETWEEN('Date'[Day],[StartDate], [EndDate] ) )

 

The StartDate = FIRSTDATE('Date'[Day])    and EndDate = LASTDATE('Date'[Day])

 

 

 

still same result .  is there any value we can get 2 een though we dont have any data for 1st week in fact .

1 ACCEPTED SOLUTION
v-huizhn-msft
Employee
Employee

Hi @Surendra_thota,

Please try to use the following formula, and check if it works.

Avgcount_test = Distinctcount([Week Ending])


Best Regards,
Angelia

View solution in original post

2 REPLIES 2
v-huizhn-msft
Employee
Employee

Hi @Surendra_thota,

Have you reslved your issue? If you have, please mark the right reply as answer, thanks.

Thanks,
Angelia

v-huizhn-msft
Employee
Employee

Hi @Surendra_thota,

Please try to use the following formula, and check if it works.

Avgcount_test = Distinctcount([Week Ending])


Best Regards,
Angelia

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.