Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
samHil
Frequent Visitor

compare values in the same column agnist current day and pay previous year

Hi, I have a dataset which has DATE, NAME, Hourbucket, Sales. I need to find out if sales was 0 for any hourbucket for a date and if true then check last year same date same hourbucket and same name to see if the sales was 0.

if both the conditions are true then "sales" else "NoSale".

Example

if Sale =0 then

check sales (Same column) a year before for the same name and hourbucket and that sales =0

then "NoSales"

else "Sales"

 

Any help will be appreciated.
This is the kind of dataset. Sorry the file is too big to get an exact sample

Namehr bucketYearMonth NameDaySales
Jon12016Nov120
Jon22016Nov12560
Jon32016Nov12647
Jon42016Nov12914
Jon22016Nov13996
Jon32016Nov13982
Jon42016Nov13664
Jon12016Nov13777
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@samHil , Try a A new column =
var _sales = sumx(filter(Table, [Name] =earlier([Name]) && [hr] =earlier([hr]) && [Month ] =earlier([Month]) && [Day] =earlier([Day])
&& [year] =earlier([year]) -1),[Sales])
return
if([sales]= 0 && (_sales+0) =0 , "NoSales" , "Sales")

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@samHil , Try a A new column =
var _sales = sumx(filter(Table, [Name] =earlier([Name]) && [hr] =earlier([hr]) && [Month ] =earlier([Month]) && [Day] =earlier([Day])
&& [year] =earlier([year]) -1),[Sales])
return
if([sales]= 0 && (_sales+0) =0 , "NoSales" , "Sales")

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.