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.
Hello, I would like to write M Code to count the number of records (in this case number of surveys) for the Year to Date. How would I write this? Thanks in advance.
If you use that fucntion you can't hard-code a year value. Instead, you need to use a column in your data that contains valid dates.
TOTALYTD(<expression>,<dates>[,<filter>][,<year_end_date>])
So if you have a column that contains some transaction date for your data, put that column in where you currently have 2023.
Cheers,
Peter
Okay, when I do this (first photo), I find I get the same count as Month to Date. Note When I do [Date].[Year](second photo) in the second function it cannot display the video.
I can't evaluate your data, but I think the problem is that (looking at your first screen-shot), you are attempting to accumulate a value of [Count of Survey Number By Month]. Try instead to base the calculation on counting the raw "Survey Number".
Consider asking this in the DAX forum, there are a lot of experts over there.
Cheers,
Peter
Hi -
I am not sure I would use M to do that, have you considered creating a measure using DAX?
Cheers,
Peter
Well I guess I want to create a measure. That would be M Code, right?
M-code is more for the manipulation of the "shape" of your data - splitting tables in two, adding or renaming columns, that kind of thing.
To create a measure you want to use DAX. Take a look at the TOTALYTD function.
Hope this helps,
Peter
Okay, thanks. Why doesn't my DAX code here seem to be working?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.