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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Summarize table - replacing blanks with 0 if there was no entry before

 

Hi all 

I need help with summarizing a table - how do I write a code that would replace blanks with zeros but only in instances when the item has not had any entries prior to that? 

Here is what visual of my data.

Rows - item ids, columns represent MonthNo. 

rigosakhx_2-1608775569907.png

EG if we look at items 00 and 01, we have sales in March and then blank in May 

On the other hand, Item 05 was introduced in July so I want to insert zeros between August and November but not before July. 

 

The current query is 

SUMMARIZE(Table A,[ItemId],[Date].[MonthNo],"Sales",SUM(Transactions[QtyABS])

 

This data is used to calculate rolling monthly average use by using AVERAGEX function. My problem is that the average function  excludes 0s which results in higher average than actual. 

 

Hope it makes sense 

5 REPLIES 5
parry2k
Super User
Super User

@Anonymous solution attached, I think this will do it.

 

Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Check this topic and see if it's helpful.

https://community.powerbi.com/t5/Desktop/Show-0-in-matrix-when-there-is-no-data-blank-Count-0-does-not/m-p/694140 

 

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.
AllisonKennedy
Super User
Super User

@Anonymous  You could define variables that look for the MIN month for each item, then IF Month > MIN month, SUM() + 0, SUM()

 

However, this might not be accurate. How do you know when an item is introduced? Do you have a DimItem table with release date or introduced date somewhere that we could access for this calculation?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Hi Allison

Hi,

Could you share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.