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.
If today is November 4 i want to calculate some measures as below requirement
1. sum(sales) between October 1 to October 4 (i.e last 1 month same period)
i tried this measure but giving the result from Oct 1 to Oct 3 but i want from oct 1 to oct 4th.
1-MonthSamePeriod = CALCULATE ( SUM ( 'Table'[Sales] ), FILTER ( 'Table', AND ( [Date] >= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, 1 ), [Date] <= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, DAY ( TODAY () ) - 1 ) ) ) )
Solved! Go to Solution.
Hi @yalla ,
Since you want to caulate 10-1 to 10-4 in this case based on 11-4, why did you use -1 in Day()?
Just delete -1 in the formula and it should work.
1-MonthSamePeriod =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER (
'Table',
AND (
[Date]
>= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, 1 ),
[Date]
<= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, DAY ( TODAY () ) )
)
)
)
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@yalla , Try like examples
Last MTD QTY forced=
var _max = date(year(today()),month(today())-1,day(today()))
return
CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
or
Last MTD QTY forced=
var _max = date(year(today()),month(today())-1,day(today()))
return
if('Date'[Date]<=_max , CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year))), blank())
in if condition is not able to pick date column.do we have other measure
Hi @yalla ,
Since you want to caulate 10-1 to 10-4 in this case based on 11-4, why did you use -1 in Day()?
Just delete -1 in the formula and it should work.
1-MonthSamePeriod =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER (
'Table',
AND (
[Date]
>= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, 1 ),
[Date]
<= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 1, DAY ( TODAY () ) )
)
)
)
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |