Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi All,
I am trying to calcuate the count for the current year & month; 2020 Jan to April (current month) and also show the same period Jan to April but for last year 2019. I have created a date table and marked it as a date table.
Date =
ADDCOLUMNS (
CALENDAR (DATE(2000,1,1), DATE(2025,12,31)),
"DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
"Year", YEAR ( [Date] ),
"Monthnumber", FORMAT ( [Date], "MM" ),
"YearMonthnumber", FORMAT ( [Date], "YYYY/MM" ),
"YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
"MonthNameShort", FORMAT ( [Date], "mmm" ),
"MonthNameLong", FORMAT ( [Date], "mmmm" ),
"DayOfWeekNumber", WEEKDAY ( [Date] ),
"DayOfWeek", FORMAT ( [Date], "dddd" ),
"DayOfWeekShort", FORMAT ( [Date], "ddd" ),
"Quarter", "Q" & FORMAT ( [Date], "Q" ),
"YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" )
)
which has a 1 to many relationship to my data table 'New Business' [Variation Issue Date]
Current Year DAX :
Did you try
CALCULATE([Count YTD], DATEADD('New Business'[Variation Issue Date],-1, year))
The variation issue date seems to have data issues, DATEADD expects a contiguous selection when the date column is not unique, has gaps or it contains time portion.
What does the time intel function base the expected min & max on, My date table has generic start and end times I haven't used a column as there are more than one table connected to it. The data is a dimension table so the dates aren't consective. Can I use a FORMAT function within the DAX to get around this problem?
Can you post sample data as text so that this can be recreated? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Hi Greg,
Thanks for the reply. I tried inserting a table but it doesn't allow for enough rows so here's some data. All 2020 and the first three months of 2019. Just a count of a column and the data field pretty simple.
https://drive.google.com/open?id=1bIyarSPC-hoU2Wa1OTOrP1xJKWZjyukE
hope it works
Hi All,
I found the problem the PYTD is returning 35976 in the top table when it should be 7686 as per bottom table. So it is summing the entire year instead of the same period in the YTD measure. This is becuase the fact table date variation issue date produces the error, Function 'SAMEPERIODLASTYEAR' expects a contiguous selection when the date column is not unique, has gaps or it contains time portion.
So becuase i have to use the the date table date I need a way to calculate for last year but current month eg. year -1, current months.
Thanks
I have wrriten the following DAX but it returns nothing.
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
33 | |
16 | |
13 | |
10 | |
8 |
User | Count |
---|---|
59 | |
20 | |
12 | |
11 | |
10 |