Forum Discussion
Dax Query Not working
- 1 year ago
Hi homelander123 ,
Thank you for reaching out to Microsoft Fabric Community.
Thank you Shravan133 for the prompt response!!
Create a datetable using the DAX code below.
DateTable =
ADDCOLUMNS (
CALENDAR (DATE(2023, 1, 1), DATE(2025, 12, 31)),
"Year", YEAR([Date]),
"Month", FORMAT([Date], "MMMM"),
"YearMonth", FORMAT([Date], "YYYY-MM")
)
Next, establish a relationship between both tables. The tables should be related based on the date and CSM date columns. Then, use the measure below to achieve the expected results. The PBIX file is also attached for reference.
CMLYNAACount =
VAR SelectedDate = MAX('DateTable'[Date])
VAR LastYearStart = DATE(YEAR(SelectedDate) - 1, MONTH(SelectedDate), 1)
VAR LastYearEnd = EOMONTH(LastYearStart, 0)
RETURN
CALCULATE(
SUM(Query1[NACCount]),
FILTER(
ALL(Query1),
Query1[CSMDate] >= LastYearStart &&
Query1[CSMDate] <= LastYearEnd
)
)
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you!!
Hi homelander123 ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If the responses has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you!!