Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
I want filter column Start(Date) only month and year.
Not mind date.
How to edit query?
Solved! Go to Solution.
@Anonymous
Just change the column back to text and use the code I gave you that works with dates stored as text
Measure = VAR __CurrentMeasure =
CALCULATE (
COUNT ( 'Before'[Start(Date)]),
FILTER (
'Before',
AND ( YEAR(DATEVALUE('Before'[Start(Date)])) = 2021 , MONTH(DATEVALUE('Before'[Start(Date)])) = 12 )
)
)
RETURN
IF ( ISBLANK ( __CurrentMeasure ), 0, __CurrentMeasure )
Phil
Proud to be a Super User!
Hi @Anonymous
You need to use DATEVALUE to convert those text values into proper dates
Measure = VAR __CurrentMeasure =
CALCULATE (
COUNT ( 'Before'[Start(Date)]),
FILTER (
'Before',
AND ( YEAR(DATEVALUE('Before'[Start(Date)])) = 2021 , MONTH(DATEVALUE('Before'[Start(Date)])) = 12 )
)
)
RETURN
IF ( ISBLANK ( __CurrentMeasure ), 0, __CurrentMeasure )
Regards
Phil
Proud to be a Super User!
Hi @Anonymous
Without seeing the data I can't do any more. I don't know what these dates stored as text look like. Are they 1 Dec 21, or 1st December 2021 or 1/12/2021 etc?
That's why you should always supply some sample data.
Can you not just change the column to Date type?
regards
Phil
Proud to be a Super User!
@PhilipTreacy Now I change format type to Date.
But I use your query but not found data.
It value in care show 0
@Anonymous
Year needs to be a 4 digit number
Month is a number from 1 to 12
Phil
Proud to be a Super User!
@Anonymous
Just change the column back to text and use the code I gave you that works with dates stored as text
Measure = VAR __CurrentMeasure =
CALCULATE (
COUNT ( 'Before'[Start(Date)]),
FILTER (
'Before',
AND ( YEAR(DATEVALUE('Before'[Start(Date)])) = 2021 , MONTH(DATEVALUE('Before'[Start(Date)])) = 12 )
)
)
RETURN
IF ( ISBLANK ( __CurrentMeasure ), 0, __CurrentMeasure )
Phil
Proud to be a Super User!
@PhilipTreacy If I change the requirement to not year=2021 , month not = 12 and column not blank measure as below.
It error
It error : Too many arguments were passed to the AND function. The maximum argument count for the function is 2.
Hi @Anonymous
OK, you can use this,
Measure = VAR __CurrentMeasure =
CALCULATE (
COUNT ( 'Before'[Start(Date)]),
FILTER (
'Before',
AND ( YEAR('Before'[Start(Date)]) = 2021 , MONTH('Before'[Start(Date)]) = 12 )
)
)
RETURN
IF ( ISBLANK ( __CurrentMeasure ), 0, __CurrentMeasure )
Regards
Phil
Proud to be a Super User!
Hi @Anonymous
Download this sample PBIX file with the following data and code
So you just want to count the number of dates equal to (or before) a specific date?
Please, always supply some sample data and your expected result.
Using this data
To count the number of dates before 1 Dec 2021 you can use this
Measure = VAR __CurrentMeasure =
CALCULATE (
COUNT ( 'Before'[Start(Date)]),
FILTER (
'Before',
'Before'[Start(Date)] < DATE(2021,12,1)
)
)
RETURN
IF ( ISBLANK ( __CurrentMeasure ), 0, __CurrentMeasure )
Regards
Phil
Proud to be a Super User!
@PhilipTreacy I want to count the number specific december 2021 only , never mind date
User | Count |
---|---|
88 | |
72 | |
69 | |
65 | |
57 |
User | Count |
---|---|
96 | |
92 | |
91 | |
75 | |
69 |