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.
Hi,
I am facing an issue I would like to get help with.
I woud like to calculate the value of the previous quarter with the following DAX:
Value T-1 = CALCULATE('Value'[Value T],DATEADD('Quarter'[Last day of Quarter],-1,QUARTER))
As you can see in the picture there are some missing values for the previous quarters, but I don't know why.
Can you help me find the problem?
Please find attached the pbix and excel files.
Kind regards,
Benjamin
Solved! Go to Solution.
Hi, @kormosb
I'd like to suggest you create a calculated column and a measure as below.
Calculated column:
YearQuarter = [Year]*10+[Q]
Measure:
LastYearQuarter Value =
var _yearquarter = SELECTEDVALUE('Quarter'[YearQuarter])
var _lastyearquarter =
CALCULATE(
MAX('Quarter'[YearQuarter]),
FILTER(
ALL('Quarter'),
'Quarter'[YearQuarter]<_yearquarter
)
)
return
IF(
NOT(ISBLANK(_lastyearquarter)),
CALCULATE(
SUM('Value'[Value]),
FILTER(
ALL('Quarter'),
'Quarter'[YearQuarter] = _lastyearquarter
)
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @kormosb
I'd like to suggest you create a calculated column and a measure as below.
Calculated column:
YearQuarter = [Year]*10+[Q]
Measure:
LastYearQuarter Value =
var _yearquarter = SELECTEDVALUE('Quarter'[YearQuarter])
var _lastyearquarter =
CALCULATE(
MAX('Quarter'[YearQuarter]),
FILTER(
ALL('Quarter'),
'Quarter'[YearQuarter]<_yearquarter
)
)
return
IF(
NOT(ISBLANK(_lastyearquarter)),
CALCULATE(
SUM('Value'[Value]),
FILTER(
ALL('Quarter'),
'Quarter'[YearQuarter] = _lastyearquarter
)
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@kormosb , With date table you can get Last qtr like
QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))
Last complete QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD( ENDOFQUARTER(dateadd('Date'[Date],-1,QUARTER))))
Last to last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-2,QUARTER)))
Next QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],1,QUARTER)))
Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,Year)))
Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(ENDOFQUARTER(dateadd('Date'[Date],-1,Year))))
trailing QTR = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,QUARTER))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...
In case you do not have date then you can use Qtr Rank to that
Same what I done for week -https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
Appreciate your Kudos.
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 |
---|---|
114 | |
105 | |
79 | |
68 | |
63 |
User | Count |
---|---|
148 | |
107 | |
106 | |
82 | |
70 |