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.
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?
And what is on the rows of the matrix?
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 )
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 )
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
57 | |
49 | |
44 | |
18 | |
18 |