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.
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?
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.