Close Menu
    Trending
    • Do You Really Need a Foundation Model?
    • xAI lanserar AI-sällskap karaktärer genom Grok-plattformen
    • How to more efficiently study complex treatment interactions | MIT News
    • Claude får nya superkrafter med verktygskatalog
    • How Metrics (and LLMs) Can Trick You: A Field Guide to Paradoxes
    • Så här påverkar ChatGPT vårt vardagsspråk
    • Deploy a Streamlit App to AWS
    • How to Ensure Reliability in LLM Applications
    ProfitlyAI
    • Home
    • Latest News
    • AI Technology
    • Latest AI Innovations
    • AI Tools & Technologies
    • Artificial Intelligence
    ProfitlyAI
    Home » Why You Should Not Replace Blanks with 0 in Power BI
    Artificial Intelligence

    Why You Should Not Replace Blanks with 0 in Power BI

    ProfitlyAIBy ProfitlyAIJune 20, 2025No Comments8 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    watching Jeffrey Wang as a live stream guest with Reid Havens, and one of many dozen great issues that Jeffrey shared with the viewers was the checklist of optimizations that the DAX engine performs when creating an optimum question plan for our measures.

    And, the one which caught my consideration was relating to the so-called “Sparse measures”:

    Screenshot from the stay stream on YouTube

    To make it easy, when you outline the measure, Formula Engine in VertiPaq will add an implicit NonEmpty filter to the question, which ought to allow the optimizer to keep away from full cross-join of dimension tables and scan solely these rows the place data for the mixture of your dimension attributes actually exist. For people coming from the MDX world, the NonEmpty perform might look acquainted, however let’s see the way it works in DAX.

    The factor that almost all resonated with me was when Jeffrey suggested in opposition to changing BLANKs with zeroes (or no matter specific values) in Energy BI calculations. I’ve already written how you can handle BLANKs and replace them with zeroes, however on this article, I wish to concentrate on the doable efficiency implications of this choice.

    Setting the stage

    Earlier than we begin, one necessary disclaimer: the advice to not change BLANK with 0 is simply that — a advice. If the enterprise request is to show 0 as an alternative of BLANK, it doesn’t essentially imply that it’s best to refuse to do it. In most eventualities, you’ll in all probability not even discover a efficiency lower, however it should rely upon a number of various factors…

    Let’s begin by writing our easy DAX measure:

    Gross sales Amt 364 Merchandise =
    CALCULATE (
        [Sales Amt],
        FILTER ( ALL ( 'Product'[ProductKey] ), 'Product'[ProductKey] = 364 )
    )

    Utilizing this measure, I wish to calculate the entire gross sales quantity for the product with ProductKey = 364. And, if I put the worth of this measure within the Card visible, and activate Efficiency Analyzer to test the instances for dealing with this question, I get the next outcomes:

    Picture by writer

    DAX question took solely 11ms to execute, and as soon as I switched to DAX Studio, the xmSQL generated by the Method Engine was fairly easy:

    Picture by writer

    And, if I check out the Question plan (bodily), I can see that the Storage Engine discovered just one current mixture of values to return our information:

    Picture by writer

    Including extra substances…

    Nevertheless, let’s say that the enterprise request is to research information for Product Key 364 on a each day stage. Let’s go and add dates to our report:

    Picture by writer

    This was once more very quick! I’ll now test the metrics throughout the DAX Studio:

    Picture by writer

    This time, the question was expanded to incorporate a Dates desk, which affected the work Storage Engine wanted to do, as as an alternative of discovering just one row, this time, the quantity is totally different:

    Picture by writer

    In fact, you’ll not discover any distinction in efficiency between these two eventualities, because the distinction is only some milliseconds.

    However that is just the start; we’re simply warming up our DAX engine. In each of those instances, as you may even see, we see solely “stuffed” values — that mixture of rows the place each of our necessities are happy — product secret’s 364 and solely these dates the place we had gross sales for this product — in the event you look totally within the illustration above, dates usually are not contiguous and a few are lacking, corresponding to January twelfth, January 14th to January twenty first and so forth.

    It is because Method Engine was sensible sufficient to eradicate the dates the place product 364 had no gross sales utilizing the NonEmpty filter, and that’s why the variety of data is 58: we’ve got 58 distinct dates the place gross sales of product 364 weren’t clean:

    Picture by writer

    Now, let’s say that enterprise customers additionally wish to see these dates in-between, the place product 364 hadn’t made any gross sales. So, the thought is to show 0$ quantity for all these dates. As already described within the earlier article, there are a number of other ways to interchange the BLANKs with zeroes, and I’ll use the COALESCE() perform:

    Gross sales Amt 364 Merchandise with 0 = COALESCE([Sales Amt 364 Products],0)

    Principally, the COALESCE perform will test all of the arguments supplied (in my case, there is just one argument) and change the primary BLANK worth with the worth you specified. Merely stated, it should test if the worth of the Gross sales Amt 364 Merchandise is BLANK. If not, it should show the calculated worth; in any other case, it should change BLANK with 0.

    Picture by writer

    Wait, what?! Why am I seeing all of the merchandise, after I filtered every part out, besides product 364? Not to mention that, my desk now took greater than 2 seconds to render! Let’s test what occurred within the background.

    Picture by writer

    As a substitute of producing one single question, now we’ve got 3 of them. The primary one is precisely the identical as within the earlier case (58 rows). Nevertheless, the remaining queries goal the Product and Dates tables, pulling all of the rows from each tables (The product desk comprises 2517 rows, whereas the Dates desk has 1826). Not simply that, check out the question plan:

    Picture by writer

    4.6 million data?! Why on Earth does it occur?! Let me do the mathematics for you: 2.517 * 1.826 = 4.596.042…So, right here we had a full cross-join between Product and Dates tables, forcing each single tuple (mixture of date-product) to be checked! That occurred as a result of we pressured the engine to return 0 for each single tuple that will in any other case return clean (and consequentially be excluded from scanning)!

    It is a simplistic overview of what occurred:

    Picture by writer

    Imagine it or not, there’s a sublime resolution to point out clean values out-of-the-box (however, not with 0 as an alternative of BLANK). You’ll be able to simply merely click on on the Date subject and select to Present gadgets with no information:

    Picture by writer

    This may show the clean cells too, however with out performing a full cross-join between the Product and Dates tables:

    Picture by writer

    We are able to now see all of the cells (even blanks) and this question took half the time of the earlier one! Let’s test the question plan generated by the Method Engine:

    Picture by writer

    Not all eventualities are catastrophic!

    Reality to be stated, we may’ve rewritten our measure to exclude some undesirable data, however it will nonetheless not be an optimum method for the engine to eradicate empty data.

    Moreover, there are specific eventualities by which changing BLANKs with zero won’t trigger a big efficiency lower.

    Let’s look at the next scenario: we’re displaying information in regards to the whole gross sales quantity for each single model. And I’ll add my gross sales quantity measure for product 364:

    Picture by writer

    As you would possibly count on, that was fairly quick. However, what’s going to occur after I add my measure that replaces BLANKs with 0, which precipitated havoc within the earlier situation:

    Picture by writer

    Hm, appears to be like like we didn’t need to pay any penalty when it comes to efficiency. Let’s test the question plan for this DAX question:

    Picture by writer

    Conclusion

    As Jeffrey Wang recommended, it’s best to avoid changing blanks with zeroes (or with some other specific values), as it will considerably have an effect on the question optimizer’s potential to eradicate pointless information scanning. Nevertheless, if for any purpose you want to substitute a clean with some significant worth, watch out when and find out how to do it.

    As traditional, it is determined by many various facets — for columns with low cardinality, or if you’re not displaying information from a number of totally different tables (like in our instance, after we wanted to mix information from Product and Dates tables), or visible varieties that don’t must show a lot of distinct values (i.e. card visible) — you will get away with out paying the efficiency worth. However, in the event you use tables/matrices/bar charts that present plenty of distinct values, ensure that to test the metrics and question plans earlier than you deploy that report back to a manufacturing setting.

    Thanks for studying!



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleUnderstanding Application Performance with Roofline Modeling
    Next Article Researchers present bold ideas for AI at MIT Generative AI Impact Consortium kickoff event | MIT News
    ProfitlyAI
    • Website

    Related Posts

    Artificial Intelligence

    Do You Really Need a Foundation Model?

    July 16, 2025
    Artificial Intelligence

    How to more efficiently study complex treatment interactions | MIT News

    July 16, 2025
    Artificial Intelligence

    How Metrics (and LLMs) Can Trick You: A Field Guide to Paradoxes

    July 16, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Are You Being Unfair to LLMs?

    July 11, 2025

    Top Scholarships To Study Artificial Intelligence Abroad In 2025 » Ofemwire

    April 4, 2025

    Use PyTorch to Easily Access Your GPU

    May 21, 2025

    OpenAI lanserar Codex AI-agent för mjukvaruutveckling

    May 17, 2025

    AI Text Classification – Use Cases, Application, Process and Importence

    April 6, 2025
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    Most Popular

    Streamlining data collection for improved salmon population management | MIT News

    April 6, 2025

    AI Medical Record Summarization: Definition, Challenges, And Best Practices

    April 9, 2025

    Why AI leaders can’t afford fragmented AI tools

    April 5, 2025
    Our Picks

    Do You Really Need a Foundation Model?

    July 16, 2025

    xAI lanserar AI-sällskap karaktärer genom Grok-plattformen

    July 16, 2025

    How to more efficiently study complex treatment interactions | MIT News

    July 16, 2025
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2025 ProfitlyAI All Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.