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
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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.