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,
If today is November 5 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)
2. sum(sales) between September 1 to September 4 (i.e last 2 month same period)
3. sum(sales) between August 1 to August 4 (i.e last 3 month same period)
Thank You
Solved! Go to Solution.
Hi @Anonymous ,
We can create measures using following measure to meet your requirement:
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 )
)
)
)
2-MonthSamePeriod =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER (
'Table',
AND (
[Date]
>= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 2, 1 ),
[Date]
<= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 2, DAY ( TODAY () ) - 1 )
)
)
)
1-MonthSamePeriod =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER (
'Table',
AND (
[Date]
>= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 3, 1 ),
[Date]
<= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 3, DAY ( TODAY () ) - 1 )
)
)
)
BTW, pbix as attached.
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
We can create measures using following measure to meet your requirement:
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 )
)
)
)
2-MonthSamePeriod =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER (
'Table',
AND (
[Date]
>= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 2, 1 ),
[Date]
<= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 2, DAY ( TODAY () ) - 1 )
)
)
)
1-MonthSamePeriod =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER (
'Table',
AND (
[Date]
>= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 3, 1 ),
[Date]
<= DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ) - 3, DAY ( TODAY () ) - 1 )
)
)
)
BTW, pbix as attached.
Best regards,
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I am unable to open the PBIX. Please share it again
You can also try datesmtd
Last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
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
I believe you want something like:
SUMX('Table',PARALLELPERIOD('Calendar'[Date],-1,MONTH),[Column)
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 |
---|---|
111 | |
95 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |