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.
I have viewed numerous posts related to this topic and unable to resolve this DAX query; the query returns no data.
Last 3 Months = CALCULATE(SUMX(Table1, Table1[SLA]), DATEADD(Table1[YYYY-MM],-3,MONTH))
I have a data table, as below and want to sum the data [for SLA] for the last 3 months (I have already created a separate DATE table and linked it to YYYY-MM in table1).
I have a Measure that does not appear in the table named SLA, reported as a percentage, based on the count of projects = Yes for SLA_Ok.
Table1
Project | Type | YYYY-MM | YYYY_Qrt | SLA_Ok |
120467 | Type4 | Oct-19 | 2019_Q4 | Yes |
118040 | Type4 | Oct-19 | 2019_Q4 | No |
120678 | Other | Sep-19 | 2019_Q3 | Yes |
120077 | Type2 | Sep-19 | 2019_Q3 | Yes |
119239 | Type3 | Aug-19 | 2019_Q3 | Yes |
118718 | Other | Aug-19 | 2019_Q3 | No |
Solved! Go to Solution.
From the help I received and a bit more searching I have been able to solve this as below;
Converting calculations to measures.
Last 3 Month Count =
CALCULATE([Count],DATESBETWEEN(table1[YYYY MM],EDATE(MIN(table1[YYYY MM]),-2),MAX(table1[YYYY MM])))
Count = COUNTROWS('table1')
Last 3 Months SLA =
CALCULATE ([SLA],DATESBETWEEN('table1'[YYYY MM], EDATE (MIN('table1'[YYYY MM]),-2), MAX('table1'[YYYY MM])))
YYYY MM in date format; e.g. Tuesday, 1 October 2019
Creating a Date table for YYYY MM (with Month and Year columns)
Hi,
This would be my approach
Hope this helps.
Thanks Ashish, I have followed your advice.
I am getting a DAX syntax error as shown below
Date Table Table1
New Column DAX
Hi,
You are using ]]. Use only ].
in case you want to use max, you need to use the filter clause. Refer example.
Sale_till_tody =CALCULATE(sum(Sales[Sales Amount]),filter(sales,Sales[Sales Date]<=maxx(Sales,Sales[Sales Date].[Date])))
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.
My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
Thanks Amitchandak, I did have a look at your example DAX.
The complication I have is that the column of interest, SLA expressed as a %, is not in the table, as it is a calculated measure, so I need to use sumx instead of sum.
I tried these 2 variants; the first one showed the row count, the second one had the same value for all the display table entries.
Last 3 Months SLA =
VAR _Cuur_start = Min('Last 3 Months Date'[Last 3 Months])
VAR _Curr_END = Max('Last 3 Months Date'[Last 3 Months])
return
calculate(SUMX(table1, table1[SLA])))
Last 3 Months SLA2 =
CALCULATE(sumx(table1, table1[SLA]),filter(table1,table1[SLA]<=MAXX(table1,table1[YYYY-MM])))
From the help I received and a bit more searching I have been able to solve this as below;
Converting calculations to measures.
Last 3 Month Count =
CALCULATE([Count],DATESBETWEEN(table1[YYYY MM],EDATE(MIN(table1[YYYY MM]),-2),MAX(table1[YYYY MM])))
Count = COUNTROWS('table1')
Last 3 Months SLA =
CALCULATE ([SLA],DATESBETWEEN('table1'[YYYY MM], EDATE (MIN('table1'[YYYY MM]),-2), MAX('table1'[YYYY MM])))
YYYY MM in date format; e.g. Tuesday, 1 October 2019
Creating a Date table for YYYY MM (with Month and Year columns)
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.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |