Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Need help optimizing DAX with SUMX

Hey everyone, 

 

I have a issue where my report is really slow, I think due to my nested measure and my final measure im using which uses the DAX Function SUMX.

 

SAIDI_CIRCUIT_SUM = SUMX(VALUES(REF_CIRCUIT[NOTIFICATION_DESCRIPTION]),[SAIDI_CKT!])

 

My question is does anyone know a more optimized version of SUMX which will give me the same result but faster. These are the amount of measures I needed to arrive at my SAIDI_CIRCUIT_SUM. Any help would be useful. 

 

What im doing is taking the first value from the from date on the slicer, taking the first value from the to date on the slicer and summing together then dividing it by 2 (As seen from measure CKTAVGMETERCNT). After that i take customer mins/ CKTAVGMETERCNT as seen with measure SAIDI_CKT! After i make it relevant only to the notification description with the measure SAIDI_CIRCUIT_SUM. 

 

CKT_FROM_DATE_FROM_SLICER = CALCULATE(MIN(DIM_DATE_CKT[DATE]),ALLSELECTED(DIM_DATE_CKT[DATE]))
 
CKTSumFromCount = CALCULATE(MIN(CV_SAP_METERCOUNT_CIRCUIT[READVALUE_FROM]), FILTER(DIM_DATE_CKT,DIM_DATE_CKT[DATE] = [CKT_FROM_DATE_FROM_SLICER]))
 
CKT_TO_DATE_FROM_SLICER = CALCULATE(MAX(DIM_DATE_CKT[DATE]),ALLSELECTED(DIM_DATE_CKT[DATE]))
 
CKTSumToCount = CALCULATE(MAX(CV_SAP_METERCOUNT_CIRCUIT[READVALUE_TO]), FILTER(DIM_DATE_CKT,DIM_DATE_CKT[DATE] = [CKT_TO_DATE_FROM_SLICER]))
 
CKT_First_Value_From_Date = CALCULATE([CKTSumFromCount],FIRSTNONBLANK(DIM_DATE_CKT[DATE], [CKTSumFromCount]))
 
CKT_Last_Value_To_Date = CALCULATE([CKTSumToCount],LASTNONBLANK(DIM_DATE_CKT[DATE], [CKTSumToCount]))
 
 
CKTMeterCount = IF(COUNT(CV_SAP_METERCOUNT_CIRCUIT[READVALUE_FROM]) = 1, 2, 2)
 
CKTAVGMETERCNT = DIVIDE([CKT_First_Value_From_Date] + [CKT_Last_Value_To_Date], [CKTMeterCount])
 
SAIDI_CKT! = IFERROR(sum(ZPM_O01_PM_OUTAGE_SUMMARY[CUSTOMER_MINUTES_FOR_OUTAGE_SUMMARY])/[CKTAVGMETERCNT],BLANK())
 
SAIDI_CIRCUIT_SUM = SUMX(VALUES(REF_CIRCUIT[NOTIFICATION_DESCRIPTION]),[SAIDI_CKT!])
 
 

3 Replies

  • Anonymous wow there is a lot more going on, in my opinion it will be easier if you put together sample data and what each measure is doing and what is the end goal, otherwise it is very hard to do reverse engineering

    • Anonymous's avatar
      Anonymous
      Not applicable

      parry2k  Greg_Deckler 

       

      Thanks for feedback, I will try to explain more details when I post in the future. Actually, my problem is solved, teamates and I will just move these measure in the backend in the calculated tables itself - thanks!