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
joshua1990
Post Prodigy
Post Prodigy

Replace Blanks in Matrix with Zero for huge table

Hi experts!

I have a data model based on 2 dimensional tables (Calendar and Article Table) and 1 transactional table (Sales).

The transactional table contains several million rows.

I have a matrix visual that shows me per article (rows) for the past 15 weeks (columns) the sales.

Since not every article shows sales for each week I have a lot of blank spaces in the matrix.

I would like to replace this blank spaces with a '0'.

I tried it using Measure + 0, but this is not working. The dax measure is running, and running without any result when I add +0 to the measure. Is this is related to the number of rows?

Any other sugestions here?

14 REPLIES 14
v-yanjiang-msft
Community Support
Community Support

Hi @joshua1990 ,

Has your problem been solved?

Best Regards,
Community Support Team _ kalyj

tamerj1
Super User
Super User

And what is on the rows of the matrix?

@tamerj1 : Article on row, week on column and sales as value

tamerj1
Super User
Super User

Hi @joshua1990 
That is because the engine is trying to optimize the caculations. Once it scans the sales table it will decide in which cells it shall perform calculation and which ones to skip. When you add +0 you are actually forcing the engine to perform the caclulation for all cells and hence more CPU time will be consumed.
You may try 

Sales Amount =
VAR SaleAmount =
    SUMX ( Sales, Sales[Amount] * Sales[Qty] )
RETURN
    IF ( ISBLANK ( SaleAmount ), 0, SaleAmount )

@tamerj1 Thanks a lot for this explanation! Do I need SUMX? Or this just an example measure? My original measure is a simple CALCULATE(SUM(Sales[Qty]), Filter X)

@joshua1990 
No you don't need. This is just an example as I did not what your measure is.

@tamerj1 : Thanks, but the DAX Measure is still running. Nothing happens. In general the report is fast using the simple sum measure. Using IF and ISBLANK ist not working here as well.

Can you please share the complete code of your measure?

SUM('SalesTrans'[Value])

@joshua1990 
Try this might be faster

Sales Amount =
VAR SaleAmount =
    SUM ( 'SalesTrans'[Value] )
RETURN
    SaleAmount * DIVIDE ( SaleAmount, SaleAmount, 0 )

@tamerj1 Thats weird. I still have blank values when I use you new measure

What is the nam of the date column in your sales table?

It's just [Date]. 

The calendar table contains the week information that I display on columns in the matrix

Tey this

Sales Amount =
VAR FirstSalesDatea =
    CALCULATE ( MIN ( 'SalesTrans'[Date] ), REMOVEFILTERS () )
VAR LastSalesDate =
    CALCULATE ( MAX ( 'SalesTrans'[Date] ), REMOVEFILTERS () )
VAR CurrentDate =
    MAX ( 'Date'[Date] )
VAR ForceZero = FirstSalesDate >= CurrentDate
    && CurrentDate <= LastSalesDate
VAR SaleAmount =
    SUM ( 'SalesTrans'[Value] )
RETURN
    SaleAmount + IF ( ForceZero, 0 )

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.

Top Solution Authors