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 a KPI table and within the table it calculates the actuals (a percentage in this case of plan vs actual). I have a formula that accurately displays current month actuals for the KPI dictated by the filter. However, I feel like it's a bit sloppy and I think I could run into troubles with it in the future. I was thinking of using DATEADD but when I tried it, I got an average of January - April instead of just April.
Current Month KPI Actuals = VAR CurrentMaxDate=MAX('KPI''s Table'[Date])
VAR CurrentMonth = MONTH(CurrentMaxDate)
Return CALCULATE(AVERAGE('KPI''s Table'[Actual]),'KPI''s Table'[Month]=CurrentMonth)
Solved! Go to Solution.
I appreciate the responses however it seems people are making it more complicated than I wanted. For this result the KPI needs two visual filters: one for month because DATEADD returns all dates and one for the KPI name that you want to see.
I appreciate the responses however it seems people are making it more complicated than I wanted. For this result the KPI needs two visual filters: one for month because DATEADD returns all dates and one for the KPI name that you want to see.
@lon0316 , This should have check date table is marked as date
Another option you can try is
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
Hi,
It is because DATEADD function will return a table that filtered by expression.
So it will not only return one month data but all months data after filtered.
If you want to cauculate the previous data, please take following steps:
1)Create a What If parameter:
Previous = GENERATESERIES(0, 10, 1)
2)Try this measure:
Measure =
CALCULATE (
AVERAGE ( 'Table'[Actual] ),
FILTER (
'Table',
MONTH ( 'Table'[Date] )
= MONTH ( TODAY () ) - Previous[Previous Value]
)
)
3)When selecting one value in slicer, it shows:
See my attached pbix file.
Best Regards,
Giotto
I appreciate the effort. Thank you for letting me know DATEADD will return all dates. I think a simple filter corrects the problem. Your result might be useful in some cases but is much more complicated than it needs to be.
@lon0316 - It's hard to tell what is going on. Is your Dates table related to your KPI's Table? Time intelligence functions are, in my opinion, a complete and utter pain to deal with and I generally try to avoid them and just use filters, because that's all they are, fitlers wrapped in a black box that are hard to understand what is really happening internally, have mediocre documentation and just generally don't work the way you would expect them to work. The funny part is that they were created to make time (well date) calculations "easier" and honestly considering the number of questions about them on the forums, failed that mission entirely. That's the other funny part, they don't actually deal with time in the sense of hours, minutes and seconds generally (some do), they really should be called "Impossible to use, black box calendar filters" in my opinion. Anyway, off my soap box...
See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...
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 |
---|---|
112 | |
97 | |
84 | |
67 | |
60 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |