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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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")

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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")

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.