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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Metricbits
Frequent Visitor

VARs inside SUMMARIZE dont work?

Hello,

 

I have problems using VARs inside SUMMARIZE. If I assign expression within the measure - it doesn't work. However, if I create a separate measure, it works fine.

 

Here is an example that works:

Measure 1:

NDR_AveRateBased_Charged =
AVERAGEX ( PipelinesMerged, PipelinesMerged[Client Charge Rate] ) * [NDR_Units_Paid]

 

Measure 2:

TEST1 =
VAR Step1 =
    IF ( HASONEFILTER ( Astute_Export[EmployeeID] ), [NDR_AveRateBased_Charged] )
VAR Step2 =
    SUMMARIZE (
        Astute_Export,
        Astute_Export[EmployeeID],
        "XYZ", [NDR_AveRateBased_Charged]
    )
RETURN
    SUMX ( Step2, [XYZ] )

 

However, I would like to avoid creating 2 measures for this, and when I try to put 1st measure as VAR, it returns much higher numbers. Here is an example:

TEST1 =
VAR Step0 =
    AVERAGEX ( PipelinesMerged, PipelinesMerged[Client Charge Rate] ) * [NDR_Units_Paid]
VAR Step1 =
    IF ( HASONEFILTER ( Astute_Export[EmployeeID] ), Step0 )
VAR Step2 =
    SUMMARIZE ( Astute_Export, Astute_Export[EmployeeID], "XYZ", Step0 )
RETURN
    SUMX ( Step2, [XYZ] )

 

I haven't used SUMMARIZE much before, the similar approach works with other functions, but SUMMARIZE I have problem with. Please help.

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Metricbits 

When a variable is calculated and stored, it is static, in your case, you need to evaluate Step0 formula in a new filter context so the formula has to be:

TEST1 =

VAR Step2 =
    SUMMARIZE ( Astute_Export, Astute_Export[EmployeeID], 
        "XYZ", 
        AVERAGEX ( PipelinesMerged, PipelinesMerged[Client Charge Rate] ) * [NDR_Units_Paid]
    )
RETURN
   if( HASONEFILTER ( Astute_Export[EmployeeID] ),
       SUMX ( Step2, [XYZ] ),
        BLANK()
    )



________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

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

View solution in original post

1 REPLY 1
Fowmy
Super User
Super User

@Metricbits 

When a variable is calculated and stored, it is static, in your case, you need to evaluate Step0 formula in a new filter context so the formula has to be:

TEST1 =

VAR Step2 =
    SUMMARIZE ( Astute_Export, Astute_Export[EmployeeID], 
        "XYZ", 
        AVERAGEX ( PipelinesMerged, PipelinesMerged[Client Charge Rate] ) * [NDR_Units_Paid]
    )
RETURN
   if( HASONEFILTER ( Astute_Export[EmployeeID] ),
       SUMX ( Step2, [XYZ] ),
        BLANK()
    )



________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

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

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 MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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