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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Replace Null with the value of the previous month

Hello Community and Thank you for your guidance ,

 

           I have sales of customer by Month He could have 0 sales for a month  I want to replace it with the sales of the previous Month in Power BI is it possible ?

CustSales Month 
A05-2021
A10004-2021
A03-2021
A12002-2021

 

the result 

CustSales Month 
A10005-2021
A10004-2021
A12003-2021
A12002-2021

 

Best Regards 

4 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Create a date like

Date = "01-" &[Month]

 

then try a new column

new column =
if([Sales] =0 ,sumx(filter(Table, eomonth([Date],0) = eomonth(earlier([Date]),-1)),[Sales]),[sales])

 

or measure using time intelligence

MTD Sales = CALCULATE([Sales],DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE([Sales],DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

if(isblank([MTD Sales]), [last MTD Sales],[MTD Sales])

View solution in original post

Anonymous
Not applicable

Hi all thank you for your suggestion . I tried your formula but i get this result : 

 

FarhaniHmida_0-1622795647485.png

 

the amount of sales in june shoud be equal to May and for each Client it should be different I Get the same amount for different Client if the sales = 0 

 

Do you have any idea 

 

and thank for this community 

 

View solution in original post

Anonymous
Not applicable

Hi @amitchandak , thank your for youe suggestion , I tried the formula i get the same result Sum all the sales of previous month for all client . 

 

FarhaniHmida_0-1622797743513.png

Do you any idea How to correct it 

 

best Regards 

View solution in original post

Hi @Anonymous ,

 

Modify the measure as below, add client condition.

Column = IF('Table'[Sales]=0,CALCULATE(SUM('Table'[Sales]),FILTER('Table','Table'[Date]=EDATE(EARLIER('Table'[Date]),-1)&&'Table'[Client]=EARLIER('Table'[Client]))),'Table'[Sales])

 

Best Regards,

Jay

 

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Thank You all for your help . Great Community 

ERD
Super User
Super User

Hi @Anonymous ,

There might be many options depending on your model, prerequisites and requirements.

Do you need a measure or a calculated column?

If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Check the formula.

Column = IF('Table'[Sales ]=0,CALCULATE(SUM('Table'[Sales ]),FILTER('Table','Table'[Month ]=EDATE(EARLIER('Table'[Month ]),-1))),'Table'[Sales ])

 9.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Anonymous
Not applicable

Hi all thank you for your suggestion . I tried your formula but i get this result : 

 

FarhaniHmida_0-1622795647485.png

 

the amount of sales in june shoud be equal to May and for each Client it should be different I Get the same amount for different Client if the sales = 0 

 

Do you have any idea 

 

and thank for this community 

 

Hi @Anonymous ,

 

Modify the measure as below, add client condition.

Column = IF('Table'[Sales]=0,CALCULATE(SUM('Table'[Sales]),FILTER('Table','Table'[Date]=EDATE(EARLIER('Table'[Date]),-1)&&'Table'[Client]=EARLIER('Table'[Client]))),'Table'[Sales])

 

Best Regards,

Jay

 

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@Anonymous , Create a date like

Date = "01-" &[Month]

 

then try a new column

new column =
if([Sales] =0 ,sumx(filter(Table, eomonth([Date],0) = eomonth(earlier([Date]),-1)),[Sales]),[sales])

 

or measure using time intelligence

MTD Sales = CALCULATE([Sales],DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE([Sales],DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

if(isblank([MTD Sales]), [last MTD Sales],[MTD Sales])

Anonymous
Not applicable

Hi @amitchandak , thank your for youe suggestion , I tried the formula i get the same result Sum all the sales of previous month for all client . 

 

FarhaniHmida_0-1622797743513.png

Do you any idea How to correct it 

 

best Regards 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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