Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi Community,
I have a measure to calculate total leaves taken which excludes weekends & public holidays. Countrows is not yeilding correct result.
For example in following, In Dec, emp 12 took 21 leaves not 13
My sample PBI file: https://1drv.ms/u/s!Ag919_pO_UKrgSjIVaFeSDgQFcn1?e=lCvuJq
Your help is very much appreciated.
Thanks
Solved! Go to Solution.
@Anonymous , Try like
Total Leaves =
CALCULATE( SUMX (
ADDCOLUMNS (
SUMMARIZE ( 'Emp Leave', 'Emp Leave'[emp_code], 'Emp Leave'[date_start], 'Emp Leave'[date_end] ),
"diff",
COUNTROWS (
FILTER (
Datedim,
Datedim[Date] >= ( 'Emp Leave'[date_start] )
&& Datedim[Date] <= ( 'Emp Leave'[date_end] ) && datedim[working days]=1
)
)
),
[diff]
), CROSSFILTER('Emp Leave'[date_start],datedim[Date],None))
Hi there,
A little tweak on the model, creating a table like this (better to be created at source though):
Emp Leave RelevantDays = -- SELECTCOLUMNS not necessary
SELECTCOLUMNS (
GENERATE (
'Emp Leave',
DATESBETWEEN( datedim[Date], 'Emp Leave'[date_start], 'Emp Leave'[date_end] )
),
"emp_code", 'Emp Leave'[emp_code],
"RelevantDates", 'datedim'[Date]
)Can make the DAX code easier:
Solution 2 =
CALCULATE (
COUNTROWS ( 'Emp Leave RelevantDays' ),
datedim[working days] = 1
)See file here.
Regards
@Anonymous , Try like
Total Leaves =
CALCULATE( SUMX (
ADDCOLUMNS (
SUMMARIZE ( 'Emp Leave', 'Emp Leave'[emp_code], 'Emp Leave'[date_start], 'Emp Leave'[date_end] ),
"diff",
COUNTROWS (
FILTER (
Datedim,
Datedim[Date] >= ( 'Emp Leave'[date_start] )
&& Datedim[Date] <= ( 'Emp Leave'[date_end] ) && datedim[working days]=1
)
)
),
[diff]
), CROSSFILTER('Emp Leave'[date_start],datedim[Date],None))
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 43 | |
| 39 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 68 | |
| 63 | |
| 31 | |
| 30 | |
| 23 |