Quantcast
Channel: Desktop topics
Viewing all articles
Browse latest Browse all 217320

add previous row values

$
0
0

Hi,

 

I have a fact table of sales and I need to get 2 new columns, wich will display Previous date of purchase and Previous sales status (both red in the table below).

 

I'm trying to get same results as with using lag/window function in SQL ( lag(date_of_purchase) over (partition by month_of_sale, customer, product order by date_of_purchase). 

Also, the problem is, I no longer can edit Query (the table in database no longer exists)..

 

month of salecustomerproductsales statusdate of purchaseprevious date of purchaseprevious sales status
Dec-16johnAbooked01-12-16nullnull
Dec-16johnAbooked20-12-1601-12-16booked
Dec-16aliciaApaid01-12-16nullnull
Jan-17johnCk111booked01-01-17nullnull
Jan-17johnCk111paid13-01-1701-01-17booked
Jan-17johnAbooked01-01-17nullnull
Jan-17johnAbooked03-01-1701-01-17booked
Jan-17aliciaCk111booked01-01-17nullnull
Jan-17aliciaCk111paid13-01-1701-01-17booked
Jan-17aliciaCk111paid20-01-1713-01-17paid

 

 

I've been trying to use calculate function with filters, but so far no useful results. I'm new at DAX, so probably I'm not using them right way..

 

Thanks in advance for any help!

Zuzana


Viewing all articles
Browse latest Browse all 217320

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>