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 am trying to calculate MAT Moving Anual Total only when I have 12 months of sales.
how can I restrict the calculation of the MAT only for a complete MAT.
My current measure formula is:
MAT =
VAR Current_Date= MAX('Aux_Date'[End of Month Date])
VAR Previous_Date= DATE(YEAR(Current_Date),MONTH(Current_Date)-12,DAY(Current_Date))
VAR Result= CALCULATE(
SUM(Vendas_Base_Data_Final[Unidades]),
FILTER(
Vendas_Base_Data_Final,
Vendas_Base_Data_Final[End of Month Date] > Previous_Date && Vendas_Base_Data_Final[End of Month Date] <= Current_Date
)
)
VAR Aux_N_Months= CALCULATE(
COUNTROWS ( VALUES ( Vendas_Base_Data_Final[End of Month Date])),
FILTER(
Vendas_Base_Data_Final,
Vendas_Base_Data_Final[End of Month Date] > Previous_Date && Vendas_Base_Data_Final[End of Month Date] <= Current_Date
)
)
Return
if (SUMMARIZE(Aux_N_Months,[Aux_N_Months])=12, Result,BLANK())
But this is not correct. Anyone can help?
Solved! Go to Solution.
I assume the date in which 12 months commenced is a fixed point in time. The simplest and most efficient solution is to just hard code it inside an if.
IF(max(fact[date]]>date(2018,3,3), :your code here: )
also, do yourself a favour and simplify your table names
instead of Vendas_Base_Data_Final
why not Data?
Hi @Patekos ,
I create the following sample data to calculate MAT Moving Anual Total only when I have 3 months of sales. . Then create measure:
MAT =
VAR Current_Date=
MAX('Aux_Date'[End of Month Date])
VAR Previous_Date=
EOMONTH(Current_Date,-3)
VAR Result=
CALCULATE(
SUM(Vendas_Base_Data_Final[Unidades]),
FILTER(
Vendas_Base_Data_Final,
Vendas_Base_Data_Final[End of Month Date] > Previous_Date
&& Vendas_Base_Data_Final[End of Month Date] <= Current_Date
)
)
VAR Aux_N_Months=
CALCULATE(
COUNTROWS ( Vendas_Base_Data_Final ),
FILTER(
ALL(Vendas_Base_Data_Final),
Vendas_Base_Data_Final[End of Month Date] > Previous_Date
&& Vendas_Base_Data_Final[End of Month Date] <= Current_Date
)
)
Return
if (Aux_N_Months=3, Result,BLANK())
This is my PBIX file.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Patekos ,
I create the following sample data to calculate MAT Moving Anual Total only when I have 3 months of sales. . Then create measure:
MAT =
VAR Current_Date=
MAX('Aux_Date'[End of Month Date])
VAR Previous_Date=
EOMONTH(Current_Date,-3)
VAR Result=
CALCULATE(
SUM(Vendas_Base_Data_Final[Unidades]),
FILTER(
Vendas_Base_Data_Final,
Vendas_Base_Data_Final[End of Month Date] > Previous_Date
&& Vendas_Base_Data_Final[End of Month Date] <= Current_Date
)
)
VAR Aux_N_Months=
CALCULATE(
COUNTROWS ( Vendas_Base_Data_Final ),
FILTER(
ALL(Vendas_Base_Data_Final),
Vendas_Base_Data_Final[End of Month Date] > Previous_Date
&& Vendas_Base_Data_Final[End of Month Date] <= Current_Date
)
)
Return
if (Aux_N_Months=3, Result,BLANK())
This is my PBIX file.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I assume the date in which 12 months commenced is a fixed point in time. The simplest and most efficient solution is to just hard code it inside an if.
IF(max(fact[date]]>date(2018,3,3), :your code here: )
also, do yourself a favour and simplify your table names
instead of Vendas_Base_Data_Final
why not Data?
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 |
---|---|
109 | |
96 | |
77 | |
66 | |
53 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |