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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

How to Calculate a Conditional Measure Before Slicer Filter is applied

I'm having trouble creating a measure that will behave in the following manner:

Existing Measures(#) > If the sum of that measure for each month is > 2000 then limit to 2000, else if < -2000 then limit to -2000 > Find the Sum based on the given date slicer and visual context

 

To my understanding, I need some way to calculate the of each month with the [NetRevenue wLimit] applied before it aggregates by Yearmonth. I'm not sure how to achieve this behavior. The examples below show I get the expected result when only one month is selected, but when I add multiple months in my date slicer the measure doesn't behave as desired. 

 

My guess is I need to use some type of iterator function(SUMX...), but I can't get anything to work. 

 

Expected Result: (Month Date Slicer)[June and July Selected]

SalesRepName

Net Revenue $

NetRevenue wLimit

Bob

200

200

Susan

-4000

-3000

 

What I getting instead [Month Date Slicer](June and July Selected)

SalesRepName

Net Revenue $

NetRevenue wLimit

Bob

200

200

Susan

-4000

-2000

 

If I expand the table to include year month the evaluated table looks like the following

SalesRepName (Column)

YearMonth(Column)

Net Revenue $ (Measure)

NetRevenue wLimit (Measure)

Bob 

202106

-1

-1

Bob

202107

201

201

Susan

202106

-1000

-1000

Susan

202107

-3000

-2000

 

Measure Definitions:

 

 

 

Net Revenue $ = ([Ending Book] - [Starting Book])

 

 

 

*Note [Ending Book] and [Starting Book] are both calculated measures using the credits table

 

 

 

 

NetRevenue wLimit =
VAR MC =
    CALCULATE (
        SUM ( Credits[Amount] ),
        Credits[Credit Type] = "Management Change Add"
            || Credits[Credit Type] = "Management Change Add Term"
            || Credits[Credit Type] = "Management Change Drop Term"
            || Credits[Credit Type] = "Management Change Drop"
    )
RETURN
    IF ( MC > 2000, 2000, IF ( MC < -2000, -2000, MC ) )

 

 

 

Model:

juliusj_0-1627396220798.png

 

Other information:

Salesrepname sourced from the historical salesroletable

Yearmonth is from the Dimension vw_Date table

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Yeah, the idea is to iterate at the level of granularity that your limit rules apply. It will look something like this:

 

Revenue with Limit =
SUMX (
    ADDCOLUMNS (
        SUMMARIZE (
            Credits,
            Credits[SalesRepName],
            vw_Date[YearMonth]
        ),
        "@MC", [MC Limit]
    ),
    [@MC]
)

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

Yeah, the idea is to iterate at the level of granularity that your limit rules apply. It will look something like this:

 

Revenue with Limit =
SUMX (
    ADDCOLUMNS (
        SUMMARIZE (
            Credits,
            Credits[SalesRepName],
            vw_Date[YearMonth]
        ),
        "@MC", [MC Limit]
    ),
    [@MC]
)
Anonymous
Not applicable

Thank you @AlexisOlson. Could you explain what the "@" simple means and where I can learn more about iterator functions?

The @ symbol is just a naming convention for a temporary column. It's not an operator or special symbol. You could remove it and it wouldn't change how the measure works.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.