dax performance
6 Topicsslow performance of the measure xAVG_STOCK_V_DAYS
I have an issue with the slow performance of the measure xAVG_STOCK_V_DAYS. In production, I have a live mode model connected to an analytical cube in Fabric. I have replicated the required tables for the calculation of the measure in the report attached here. The tables in production are dozens of times larger. The xAVG_STOCK_V_DAYS measure takes approximately 8 minutes to compute in production. I would appreciate assistance in improving the measure's performance. https://drive.google.com/file/d/1O_jrsYubmYROx6N-_bBOJrHf4oG7oTXT/view?usp=sharing xAVG_STOCK_V_DAYS= xAVG_STOCK_V_DAYS = VAR DataMin = MIN ( DimDate[Date_Name] ) VAR DataMax = MAX ( DimDate[Date_Name] ) RETURN CALCULATE ( AVERAGEX ( SUMMARIZE ( 'DimDate', DimDate[Date_Name] ), [Stock] ), DATESBETWEEN ( DimDate[Date_Name], DataMin, DataMax ) ) Stock= Stock = VAR DateChoose = CALCULATE ( MAX ( DimDate[Date_Name] ) ) + 1 RETURN CALCULATE ( SUMX ( FactInventoryStore, ( FactInventoryStore[Units] ) ), ALL ( 'DimDate' ), FactInventoryStore[TECH_DateStart] <= DateChoose, FactInventoryStore[TECH_DateEnd] > DateChoose )Solved1.4KViews0likes8CommentsOptimizing Measure performance (open incidents running total)
Dear All, A couple of days ago I posted a topic for help with a measure which calculates the number of open incidents per day. I've already made some small adjustments since then. https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Open-Incidents-per-day/m-p/3968348 Objective of this measure is to calculate to number of incidents where the last status in the filter context of the visual is not closed. The measure I created works in the sense that it shows the correct results. However, already in my test-environment which is only ~15.000 rows, the performance isn't great. When I attempt to run the measure in my live environment with ~15.000.000 rows, it's completely un-useable, as in, I just get an error that it runs out of memory. As far as I can see there are 2 issues: The number of iterations on the facttable A rolling date range is intensive as the datasize keeps getting larger day-by-day (_Date[Date] <= MaxDate) I'm however at a loss on how to calculate this result in a different way. What would be the correct way to re-write this measure so that it's usable in a larger data-model? For reference, my fact table (Raw_Transactions) looks something like the screenshots below. Only connected table is a date table called '_date'. Thanks in advance for the assistance! Open Incidents (Summarize) = VAR MaxDate = MAX('_Date'[Date]) VAR Result = CALCULATE( COUNTX( ADDCOLUMNS( SUMMARIZE( Raw_Transactions, Raw_Transactions[IncidentId], Raw_Transactions[CountOfTransaction] ), "@MaxTransaction", VAR _Result = CALCULATE( MAX( Raw_Transactions[CountOfTransaction] ), ALLEXCEPT( Raw_Transactions, Raw_Transactions[IncidentId] ), _Date[Date] <= MaxDate ) RETURN IF( _Result = Raw_Transactions[CountOfTransaction], _Result ) ), [@MaxTransaction] ), _Date[Date] <= MaxDate, Raw_Transactions[TransactionType] <> "Closed" ) RETURN ResultSolved665Views0likes2CommentsPoor performance of SUMX and Calculate measure
Hi Community After computing some custom time intelligence measures my report performance went really bad. Due to not following a Gregorian calendar i have based my measures on the article by SQLBI gents: https://www.daxpatterns.com/custom-time-related-calculations/ Since I'm utilizing their measures, I suspect that the performance issues may stem from my general Sales measure, which is not straightforward due to the need to incorporate currency conversion. I attempted to analyze this using DAX Studio, but I believe my limited DAX knowledge is hindering the solution. Here is my Sales measure DAX expression: Sales = SUMX ( 'FactSales', 'FactSales'[Revenue] * CALCULATE ( FIRSTNONBLANK ( 'DimCurrency'[Currency Rate], 1 ), USERELATIONSHIP ( 'FactSales'[CurrencyKey], 'DimCurrency'[CurrencyKey] ) ) ) I have a Many-to-Many relationship between FactSales and DimCurrency, and the relevant columns are as follows: Currency Name Currency CurrencyYear FromCurrency Currency Rate CurrencyKey Swiss Franc CHF 2021 ALL 0,008601457 2021ALL Swiss Franc CHF 2021 CNY 0,138102169 2021CNY Swiss Franc CHF 2021 MXN 0,045118218 2021MXN Swiss Franc CHF 2021 QAR 0,265412088 2021QAR I'm unsure whether using SUMX is the most optimal approach and how to best apply the Currency Rate in this scenario.. Thanks in advanceSolved1.5KViews0likes4CommentsFiltering to columns that contain a certain string, & only on and after a given date
Hi community, I was given help months ago to come up with a script; it's been working wonderfully. I now need to expand it. This is how it looks currently: CALCULATETABLE ( ADDCOLUMNS ( SUMMARIZE ( 'CM360', 'CM360'[Date], 'CM360'[Placement ID] ), "Cost-per-day", CALCULATE( SUM(('CM360'[impressions])) / 1000) * 4 ), 'CM360'[site_cm360] = "Programmatic Ads" ) --------------------------------------------------------------------------------------------------------------------------------- You can see we've created a calculated table where we've taken the [Date] and [Placement ID] columns from an existing table, 'CM360'. We've then created another column, "Cost-per-day", calculated by taking [impressions], dividing that by 1000, then multiplying by 4 dollars. Only where the column, 'CM360'[site_cm360], contains "Programmatic Ads". I would now like to expand that script to something like this: CALCULATETABLE ( ADDCOLUMNS ( FILTER ( 'CM360', (CONTAINSSTRING('CM360' ['Placement'], “banner”)), 'CM360'[Date] >= 01/09/2022 ), SUMMARIZE ( 'CM360', 'CM360'[Date], 'CM360'[Placement ID] ), "Cost-per-day", CALCULATE( SUM(('CM360'[impressions])) / 1000) * 5.00 ), 'CM360'[site_cm360] = "Programmatic Ads" OR “iAgency” ) I wish to filter what we were doing before to rows where 'CM360' ['Placement'] column contains the string "banner". And only where those rows have the date on or after September 1st 2022. Additionally, in that last line, I wish to expand it so it now looks for those two different values in the column, 'CM360'[site_cm360] Please can you look at my expanded script and help me understand how you would write it because I don't think this is how it should be written in DAX. thank-you 🙂Solved1.6KViews0likes3CommentsPerformance Issue with COUNTROWS Summarize
Hi, I need somehelp in rewriting my DAX Measure. Below Measure is taking atleast 2-3 mins to get the data from the tables. [Demand],[MonthlySupply] &[NetAvailSupplyDemand] are existing measures in the Cube with some inbuilt logic. I need to get the count of distinct product ID's based on conditions used in the measure. I have many other dimensions in the cube and below measure should be able to return data based on the selection ( like Area/ Time). How can i better write the below measure and give the same expected output? For context - product table has 1.6M unique products, Demand table has 215M records and Supply table has 147M records Product Coverage:= VAR RowCount = COUNTROWS ( FILTER ( SUMMARIZE ( 'Demand Table', 'Product'[ID] ), (IF ( ( ( ISBLANK ( [Demand] ) = TRUE || [Demand] <= 0 ) && ( ISBLANK ( [MonthlySupply] ) = TRUE || [MonthlySupply] <= 0 ) && ( ISBLANK ([NetAvailSupplyDemand] ) = TRUE | [NetAvailSupplyDemand] <= 0 ) ) || ( (ISBLANK ( [Demand] ) = TRUE || [Demand] <= 0 ) && [MonthlySupply] > 0), -1, IF (( ISBLANK ( [Demand] ) = FALSE || [Demand] > 0) && ( ISBLANK ( [MonthlySupply] ) = TRUE|| [MonthlySupply] = 0),-1,[NetAvailSupplyDemand]) ) >= 0 ))) RETURN IF ( ISBLANK ( RowCount ) = TRUE && [NetAvailSupplyDemand] <= 0,0,RowCount )2KViews0likes5CommentsHow to improve performance issues for DAX Formula
Hello, I have a report I am looking to publish, however certain visuals are prooving to have some performance issues, mainly due to a DAX measure they all rely on. This is the lowdown of my issue: 1) I have a data model with a live connection (SASS), which has a fact table with about 370,000 lines (orders). I am attempting to calculate the lead time (date difference between 2 columns) for each line where the order line meets certain filter requirements. 2) From here I am attempting to calculate the weighted average lead time over time (ordered units * Lead time / total ordered units). To do this, I am using the below DAX to filter the data model, and get an average weighted lead time that can be displayed over time, by supplier, by country etec. The DAX formula for this is below: _X̄Production LT = // = SUMPRODUCT ( PO order qty, Lead time) over total Ordered qty VAR _FilteredTable = // First create a table with all the filters required: CALCULATETABLE( 'PO Daybook', KEEPFILTERS ( 'Product'[Newness Classification] <> "Collab"), KEEPFILTERS ( ISBLANK('PO Daybook'[Customer Reference Number]) && 'PO Daybook'[__01. Production LT] > 49 && NOT( ISBLANK('PO Daybook'[12. Available Ship Date] ) ) ) ) VAR _NewTotalqty = // Calculating Total Ordered qty from filtered table CALCULATE ( sumx ( SUMMARIZE ( _FilteredTable, 'PO Daybook'[PO Number], "Qty", [01. Ordered Units] ), [Qty] ) ) VAR _NewSumProdLTandQty = // sum product calculation of LT and PO qty, where LT is a calculated column that needs to be added sumx ( SUMMARIZE ( _FilteredTable, 'PO Daybook'[__01. Production LT], "qty", [01. Ordered Units] ), [qty] * 'PO Daybook'[__01. Production LT] ) Return // Weighted average LT DIVIDE( _NewSumProdLTandQty, _NewTotalqty ) My big problem is that this is taking a lot of memory and is taking a long time for some of my visuals to load. I have filters on all pages applied also, in addition to the filters in the DAX formula. The visuals take up to 19706 ms based on the performance analyzer, and when published sometimes doesn't load at all. My DAX was written so that it could work and I get the results I want, but I'm not good enough to optimise it from here. My question is, can I improve the DAX code to make it run more efficiently? Where are the issues stemming from, and are there any workarounds? Thank you in advance, IASolved2.1KViews0likes2Comments