Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Learner27
Helper III
Helper III

Correct my Summarize Measure

Hi Everyone

"The measure below is functioning correctly, and the values it produces are accurate. However, I am facing performance issues. To address this problem, I attempted to create another measure using the SUMMARIZE function. Unfortunately, the new measure does not provide correct values like the previous measure. I would appreciate your suggestions and ideas to help me resolve this issue."

---using calculate

Commercial  Install = 

Var _le = CALCULATE(SUM(ST_Activity_Report[PaidDuration]),ST_Activity_Report[BusinessUnit]
IN {"Commercial Install","Commercial - Installs","Commercial Services - Buffalo"},
USERELATIONSHIP(ST_Activity_Report[Indirect Key],ST_PFP_Report[ID key]))

Var _Lab = CALCULATE(SUM(Install_Input[LaborEarnings]),ST_PFP_Report[InvoiceBusinessUnitName]  
IN {"Commercial Install","Commercial - Installs","Commercial Services - Buffalo"},
USERELATIONSHIP(Install_Input[PFPWeekly_Yearweeknum],ST_PFP_Report[Jobtime_Yearweeknum]))
Var _Install = IF(_Lab> 0, _Lab,_le * [#Rate For Work SPRT])
Return IF(_Install = BLANK(),0,_Install)

-----Using No Caluculate

Please correct my SUMMARIZE measure, or alternatively, suggest a low-performance measure. Your assistance would be greatly appreciated.

Commercial instal= 
var LE_act=  SUMMARIZE(filter(ST_Activity_Report,ST_Activity_Report[BusinessUnit]
IN {"Commercial Install","Commercial - Installs","Commercial Services - Buffalo"} )
,ST_Activity_Report[Indirect Key]
,"@sum",sum(ST_Activity_Report[PaidDuration]))
Var PFP_LE =  sumx(VALUES(ST_PFP_Report[ID key]),
var FILTERED=FILTER(LE_act,[ID key]=[Indirect Key])
Return
sumx(FILTERED,[@sum]))
var Lab_act=  SUMMARIZE(Install_Input,Install_Input[PFPWeekly_Yearweeknum]
,"@sum",sum(Install_Input[LaborEarnings]))

 Var _Pfp_table = SUMMARIZE(FILTER(ST_PFP_Report,ST_PFP_Report[InvoiceBusinessUnitName]  
IN {"Commercial Install","Commercial - Installs","Commercial Services - Buffalo"})
,
ST_PFP_Report[Jobtime_Yearweeknum])

 Var PFP_Lab =  sumx(_Pfp_table,
var FILTERED=FILTER(Lab_act,[Jobtime_Yearweeknum]=[PFPWeekly_Yearweeknum])
Return
sumx(FILTERED,[@sum]))

 Return IF(PFP_Lab > 0 ,PFP_Lab + 0,PFP_LE * [#Rate For Work SPRT] + 0)

 

1 REPLY 1
rubayatyasmin
Super User
Super User

Hi, @Learner27 

 

Try this code. It should improve the performance. 

 

Commercial Install =

Var _le =
CALCULATE (
SUM ( ST_Activity_Report[PaidDuration] ),
ST_Activity_Report[IsCommercialInstall],
USERELATIONSHIP ( ST_Activity_Report[Indirect Key], ST_PFP_Report[ID key] )
)

Var _Lab =
CALCULATE (
SUM ( Install_Input[LaborEarnings] ),
ST_PFP_Report[IsCommercialInstall],
USERELATIONSHIP ( Install_Input[PFPWeekly_Yearweeknum], ST_PFP_Report[Jobtime_Yearweeknum] )
)

Var _Install =
IF ( _Lab > 0, _Lab, _le * [#Rate For Work SPRT] )

Return
IF ( ISBLANK ( _Install ), 0, _Install )

 

Here, ST_Activity_Report[IsCommercialInstall] and ST_PFP_Report[IsCommercialInstall] are new calculated columns.

You can create IsCommercialInstall column like this:

 

IsCommercialInstall =
IF (
ST_Activity_Report[BusinessUnit] IN {"Commercial Install","Commercial - Installs","Commercial Services - Buffalo"},
TRUE,
FALSE
)

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors