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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
ihmerr2c
Frequent Visitor

Simplifying so that it works faster

AllocatedAmountp2 =
CALCULATE (
    SUMX (
        SUMMARIZE (
            'mediware vw_EMRToBilling',
            'mediware dimFacility'[FacilityName],  -- Use the correct column name
            'mediware vw_EMRToBilling'[bsr_Visits],
            'mediware vw_EMRToBilling'[feeschedc],
            'mediware vw_EMRToBilling'[Contractper],
            "TotalAmount", [TotalAmountMeasure],
            "ServedHours", [ServedHoursMeasure],
            "TotalServedHoursWeek", [TotalServedHoursWeekMeasure]
        ),
        IF (
            [bsr_Visits] > 1,
            [TotalAmount] * DIVIDE([ServedHours], [TotalServedHoursWeek]) * [Contractper],
            IF (
                [feeschedc] = "Unknown",
                [TotalAmount] * 1,
                [TotalAmount] * [Contractper]
            )
        )
    )
)
I have this measure that works correct in the visuals, but it works really slow all of my visuals can any one recom. a way to rewrite it so that it works faster or suggest another way to get the same results?

Heres my data model

ihmerr2c_0-1703963992625.png

 

2 REPLIES 2
Fowmy
Super User
Super User

@ihmerr2c 

Try the following version:

AllocatedAmountp2 =

    SUMX (
        ADDCOLUMNS (
            SUMMARIZE (
                'mediware vw_EMRToBilling',
                'mediware dimFacility'[FacilityName],
                'mediware vw_EMRToBilling'[bsr_Visits],
                'mediware vw_EMRToBilling'[feeschedc],
                'mediware vw_EMRToBilling'[Contractper]
            ),
            "TotalAmount", [TotalAmountMeasure],
            "ServedHours", [ServedHoursMeasure],
            "TotalServedHoursWeek", [TotalServedHoursWeekMeasure]
        ),
        VAR __TotalAmount = [TotalAmount]
        VAR __Contractper = [Contractper]
        RETURN
            IF (
                [bsr_Visits] > 1,
                __TotalAmount * DIVIDE ( [ServedHours], [TotalServedHoursWeek] ) * __Contractper,
                IF ( [feeschedc] = "Unknown", __TotalAmount * 1, __TotalAmount * __Contractper )
            )
    )



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

123abc
Community Champion
Community Champion

  1. Avoid Using SUMMARIZE in CALCULATE: The SUMMARIZE function can be computationally expensive, especially if your data table is large. Instead, try to create separate measures for aggregated calculations and use them in your main measure.

  2. Break Down the Measure: Try to break down the measure into smaller parts and then combine them. For instance, create separate measures for TotalAmount, ServedHours, and TotalServedHoursWeek and then use them in your main measure.

  3. Optimize IF Conditions: Instead of using nested IF conditions, try to use logical functions like SWITCH.

Here's a simplified version of your measure:

 

AllocatedAmountp2 =
VAR TotalAmountValue = [TotalAmountMeasure]
VAR ServedHoursValue = [ServedHoursMeasure]
VAR TotalServedHoursWeekValue = [TotalServedHoursWeekMeasure]

RETURN
CALCULATE (
SUMX (
'mediware vw_EMRToBilling',
VAR CalculatedAmount =
SWITCH (
TRUE (),
'mediware vw_EMRToBilling'[bsr_Visits] > 1, TotalAmountValue * DIVIDE(ServedHoursValue, TotalServedHoursWeekValue) * 'mediware vw_EMRToBilling'[Contractper],
'mediware vw_EMRToBilling'[feeschedc] = "Unknown", TotalAmountValue * 1,
TotalAmountValue * 'mediware vw_EMRToBilling'[Contractper]
)
RETURN
CalculatedAmount
)
)

 

Please note the following:

  • This is a simplified version, and you may need to adjust it based on your specific requirements and data model.
  • Ensure that the individual measures (TotalAmountMeasure, ServedHoursMeasure, TotalServedHoursWeekMeasure) are optimized for performance.
  • Consider creating necessary relationships, indexes, or optimizing your data model to improve overall performance.

If the performance issue persists, you might need to look into optimizing your data model, considering hardware resources, or restructuring your data.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.