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 Guys,
I'm using a measure to know the accumulated result of the last 3 months, but I would like to get the result of the last 3 months without counting the current month. How could I do this?
My measure:
CALCULATE(
[_Total vendas],
DATESINPERIOD(d_calendario[Date],MAX(d_calendario[Date]),-3,MONTH))
The result I want to get:
Solved! Go to Solution.
Hiii,
If you search and read the explanations for STARTOFMONTH and DATESINPERIOD Functions, you can get the result you are looking for by measure below:
CALCULATE (
[_Total Vendas],
DATESINPERIOD (
d_calendario[Date],
STARTOFMONTH ( DATEADD ( d_calendario[Date], -3, MONTH ) ),
+2,
MONTH
)
)
Notice that it is more general than the thing you wanted. Actually it calculates the previous 3months per month (for example if your month is Dec, then it calculates over Sept, Oct, Nov).
So If you only want to calculate previous 3months based on current month, you need to change it accordingly.
Regards,
Loran
Lets do it completely in another way.
1-In your DateTable, Create a calculated column as below:
Hiii,
If you search and read the explanations for STARTOFMONTH and DATESINPERIOD Functions, you can get the result you are looking for by measure below:
CALCULATE (
[_Total Vendas],
DATESINPERIOD (
d_calendario[Date],
STARTOFMONTH ( DATEADD ( d_calendario[Date], -3, MONTH ) ),
+2,
MONTH
)
)
Notice that it is more general than the thing you wanted. Actually it calculates the previous 3months per month (for example if your month is Dec, then it calculates over Sept, Oct, Nov).
So If you only want to calculate previous 3months based on current month, you need to change it accordingly.
Regards,
Loran
@MohammadLoran25 How would this measurement look from a selected date? Can you help me?
What do you mean exactly?
As I said it is different per month. For example if the month in your table row is Dec, then the previous 3 months would be Sept, Oct, Nov in order.
In the above-mentioned example, the statement below:
STARTOFMONTH ( DATEADD ( d_calendario[Date], -3, MONTH ) )
would be the first day of Sept
then through:
DATESINPERIOD(...., +2,Month)
It would include the Sept, Oct and November that finally filter d_calendario[Date]
I got what you need.
The measure that I wrote works in this case as well.
Is there anything wrong with that?
@MohammadLoran25 The measure is returning the last 3 months always starting from the current month.
Lets do it completely in another way.
1-In your DateTable, Create a calculated column as below:
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 |
---|---|
104 | |
101 | |
79 | |
72 | |
64 |
User | Count |
---|---|
142 | |
108 | |
101 | |
81 | |
74 |