Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. 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 |
---|---|
25 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
25 | |
12 | |
11 | |
10 | |
6 |