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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
William_Moreno
Helper II
Helper II

Return null in a specific condition

Hello people,

I need help from the experts powerbi.

I have the following spreadsheet, formed by the fields: ID_PRODUCT, SALES_MONTH, QTY.

From this, I want to create two new columns:

  • FIRST SALE - column that refer to the month of first sale that occurred for a given product;
  • QTY (REVIEWED) - it is expected in the cases where the month (SALES_MONTH) is before that FIRST SALE result value equals null not zero.
ID PRODUCTSALES_MONTHQTYFIRST SALEQTY (REVIEWED)
10050010001/01/2020001/05/2020null
10050010001/02/2020001/05/2020null
10050010001/03/2020001/05/2020null
10050010001/04/2020001/05/2020null
10050010001/05/2020100001/05/20201000
10050010001/06/2020150001/05/20201500
10050010001/07/2020200001/05/20202000
10050010001/08/2020300001/05/20203000

 

Is it possible?

Thanks in advance!

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@William_Moreno - First will be:

 

First = 
    MINX(FILTER('Table (27)',[ID PRODUCT]=EARLIER([ID PRODUCT]) && [SALES_MONTH]>=EARLIER([SALES_MONTH]) && [QTY]<>0),[SALES_MONTH])

 

 Reviewed

 

Reviewed = IF([SALES_MONTH]<[First] && [QTY]=0,BLANK(),[QTY])

PBIX attached.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

@William_Moreno - First will be:

 

First = 
    MINX(FILTER('Table (27)',[ID PRODUCT]=EARLIER([ID PRODUCT]) && [SALES_MONTH]>=EARLIER([SALES_MONTH]) && [QTY]<>0),[SALES_MONTH])

 

 Reviewed

 

Reviewed = IF([SALES_MONTH]<[First] && [QTY]=0,BLANK(),[QTY])

PBIX attached.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Greg, thank you for your post.

In my pbi archive I've changed just one signal of the function, like this:

 

 

First = 
    MINX(FILTER('Table (27)',[ID PRODUCT]=EARLIER([ID PRODUCT]) && [SALES_MONTH]<=EARLIER([SALES_MONTH]) && [QTY]<>0),[SALES_MONTH])

 

amitchandak
Super User
Super User

@William_Moreno ,

 

First Sales = minx(filter(Retail, Retail[SALES_MONTH]=EARLIER(Retail[PRODUCT])),Retail[SALES_MONTH])

 

I did not second, How can we have something before first sales?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Yes, you're right but, when this field is zero not null, the average is changed. Imagine if we were talking about a new product, month before that first sale it can not influence the average, Do you agree? 

Anyway thank you for your post.

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors