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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
_Melenios_
Helper I
Helper I

DAX Measure > Count how many Weekends(Sat or Sun separate) each employee worked

Hey all,

 

I have a date table with employees ids, dates,hours for each day and a helper column to identify the number of each day.

 

What i want is to count how many days for each week period(or month or..) EACH agent worked and then create a % of weekend days worked / total days worked for the selected period.

 

I tried the one below  which counts correct if  i select from the slicer each agent but doesn't sum correct if i select more than one emploeyee or if i clean the slicer .

 

Worked_WeekendDay =
CALCULATE(DISTINCTCOUNT(FACT_Wrkd[Data]),
FILTER(FACT_Wrkd,
FACT_Wrkd[Day Name] = 6 || FACT_Wrkd[Day Name] = 7))

 

 

Any suggestion would be appreciated!

 

Cheers

 

 

 

1 ACCEPTED SOLUTION

@_Melenios_ , Sorry, My mistake

 

CALCULATE(countrows(SUMMARIZE(FACT_Wrkd, FACT_Wrkd[Data],FACT_Wrkd[agent])),
FILTER(FACT_Wrkd,
FACT_Wrkd[Day Name] = 6 || FACT_Wrkd[Day Name] = 7))

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@_Melenios_ , Try like

CALCULATE(SUMMARIZE(FACT_Wrkd, FACT_Wrkd[Data],FACT_Wrkd[agent]),
FILTER(FACT_Wrkd,
FACT_Wrkd[Day Name] = 6 || FACT_Wrkd[Day Name] = 7))

Hi @amitchandak ,

 

Thanks for your suggestion but, unfortunatelly I get this error if i filter some employees :

 

" A table of multiple values was supplied where a single value was expected" 

 

and in some others it's returning just the real date of a weekend instead of the count of weekend days.

 

Cheers

 

@_Melenios_ , Sorry, My mistake

 

CALCULATE(countrows(SUMMARIZE(FACT_Wrkd, FACT_Wrkd[Data],FACT_Wrkd[agent])),
FILTER(FACT_Wrkd,
FACT_Wrkd[Day Name] = 6 || FACT_Wrkd[Day Name] = 7))

Thanks a lot @amitchandak  , i was blind as well.

 

Adding the countrows did the job!

 

Cheers

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.