The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I have the following formula below in DAX, to calculate customers who NEVER PURCHASED BUT PURCHASED in the last two months. How do I use SAMEPERIODLASTYEAR for her?
Solved! Go to Solution.
Please try
Novos Clientes Bimestrais PY =
VAR PreviousYearDate =
DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )
VAR AllOldCustomers =
CALCULATETABLE (
VALUES ( SBOPRODMS[Nome do PN] ),
SBOPRODMS,
SBOPRODMS[Data NF] < PreviousYearDate - 60,
SBOPRODMS[Documento] = "Nota fiscal de saída"
)
VAR AllNewCustomers =
CALCULATETABLE (
VALUES ( SBOPRODMS[Nome do PN] ),
SBOPRODMS[Data NF] < PreviousYearDate,
SBOPRODMS[Documento] = "Nota fiscal de saída"
)
RETURN
IF (
ISBLANK ( ( COUNTROWS ( EXCEPT ( AllNewCustomers, AllOldCustomers ) ) ) ),
0,
COUNTROWS ( EXCEPT ( AllNewCustomers, AllOldCustomers ) )
)
Please try
Novos Clientes Bimestrais PY =
VAR PreviousYearDate =
DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )
VAR AllOldCustomers =
CALCULATETABLE (
VALUES ( SBOPRODMS[Nome do PN] ),
SBOPRODMS,
SBOPRODMS[Data NF] < PreviousYearDate - 60,
SBOPRODMS[Documento] = "Nota fiscal de saída"
)
VAR AllNewCustomers =
CALCULATETABLE (
VALUES ( SBOPRODMS[Nome do PN] ),
SBOPRODMS[Data NF] < PreviousYearDate,
SBOPRODMS[Documento] = "Nota fiscal de saída"
)
RETURN
IF (
ISBLANK ( ( COUNTROWS ( EXCEPT ( AllNewCustomers, AllOldCustomers ) ) ) ),
0,
COUNTROWS ( EXCEPT ( AllNewCustomers, AllOldCustomers ) )
)
Hello:
Once you have you measure for this year, I'll name it Measure A then
SPLY = CALCULATE([Measure A], SAMEPERIODLASTYEAR([Dates, Date]))
Dates[Date] is the date field from your date table. It is critical to have date table, marked as date table and connected to your fact table with one to many relationship. Then the time intel functions work as expected.
I hope this helps!
I used it as directed and got the same result as the current period:
Hi Diego:
I will attah a file. Please look at inventory measure and Inv SPLY. This should help explain. The Date Table plays a big role in this.
https://drive.google.com/file/d/14G9U23xIV9_f57l2M7ChY-KWPif8M3Dp/view?usp=sharing
Hi Diego
try delete ".[Date]" part. If not working try by adding REMOVEFILTERS ( dCalendario )
User | Count |
---|---|
15 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
24 | |
20 | |
12 | |
9 | |
7 |