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
genaussie
Frequent Visitor

Dynamic Measure Calculation - Period over Period (vs last month)

Hi All,

I've been having some real troubles with this one. The requirements are:
- trying to calculate the green below, which would be dynamic based on the selected Reporting Period (slicer) by the user. I assume this would need to be a measure and not a column, as my understanding is that columns cannot be dynamic based on slicer selection.

- the purpose is for 2x single-selection filters that use the Slicer (new) visual, so the user can click on the slicer and only see the projects that have increased (or decreased) vs last period. These rely upon the Risk Forecast Movement calculated column - one is filtered for 'Increase' and the other for 'Decrease'.

- the idea is to align the movement of the selected project/period with the previous project/period, so a project does not disappear from the table even if the movement has changed from previous month. Only the selected period and previous period are relevant, and the Reportable Flag should equal "Yes" for both periods.

 

ColumnColumnColumnColumnCalculated ColumnCalculated MeasureSlicer Selection by user
Project NumberReporting PeriodReportable FlagRisk ForecastRisk Forecast MovementCurrent PeriodReporting Period = 15/11/2024Reporting Period = 15/12/2024
115/10/2024Yes10  Increase 
215/10/2024Yes20  Decrease 
315/10/2024Yes30    
115/11/2024Yes15Increase IncreaseDecrease
215/11/2024Yes5Decrease DecreaseIncrease
315/11/2024Yes30   Increase
115/12/2024Yes10DecreaseCurrent Period Decrease
215/12/2024Yes25IncreaseCurrent Period Increase
315/12/2024Yes40IncreaseCurrent Period Increase
2 ACCEPTED SOLUTIONS
DataNinja777
Super User
Super User

Hi @genaussie ,

 

To calculate the desired movement dynamically, we will use the following DAX measures:

  1. Measure for Current Period Risk Forecast:
Current Period Risk Forecast = 
CALCULATE(
    MAX('Table'[Risk Forecast]),
    FILTER(
        'Table',
        'Table'[Reporting Period] = SELECTEDVALUE('Table'[Reporting Period]) &&
        'Table'[Reportable Flag] = "Yes"
    )
)
  1. Measure for Previous Period Risk Forecast:
Previous Period Risk Forecast = 
CALCULATE(
    MAX('Table'[Risk Forecast]),
    FILTER(
        'Table',
        'Table'[Reporting Period] = EDATE(SELECTEDVALUE('Table'[Reporting Period]), -1) &&
        'Table'[Reportable Flag] = "Yes"
    )
)

3. Measure for Risk Forecast Movement:

 

Risk Forecast Movement Measure = 
VAR CurrentRisk = [Current Period Risk Forecast]
VAR PreviousRisk = [Previous Period Risk Forecast]
RETURN
    IF(
        ISBLANK(CurrentRisk) || ISBLANK(PreviousRisk),
        BLANK(),
        IF(
            CurrentRisk > PreviousRisk, 
            "Increase", 
            IF(
                CurrentRisk < PreviousRisk, 
                "Decrease", 
                "No Change"
            )
        )
    )

4. Measure for Filtering Projects Based on Slicer Selection:

Filtered Projects = 
VAR Movement = [Risk Forecast Movement Measure]
RETURN
    IF(
        Movement = SELECTEDVALUE('Slicer Table'[Movement]),
        1,
        0
    )

These measures dynamically calculate the movement based on the selected reporting period and ensure alignment between the current and previous periods. The Filtered Projects measure is applied as a visual-level filter set to = 1 in the table visual to filter projects based on the selected movement ("Increase" or "Decrease") in the slicer.

 

Best regards,

 

View solution in original post

genaussie
Frequent Visitor

Hi All,
After some additional analysis, I have discovered the best and easiest solution for this particular scenario in my report is to:

1. Utilise the Risk Forecast Movement (Calculated Column) as the slicer AND

2. Any calculated measures in the Matrix table relating to Previous Period needs to ignore the above slicer by including in the calc: REMOVEFILTERS('Table'[Risk Forecast Movement])

View solution in original post

5 REPLIES 5
genaussie
Frequent Visitor

Hi All,
After some additional analysis, I have discovered the best and easiest solution for this particular scenario in my report is to:

1. Utilise the Risk Forecast Movement (Calculated Column) as the slicer AND

2. Any calculated measures in the Matrix table relating to Previous Period needs to ignore the above slicer by including in the calc: REMOVEFILTERS('Table'[Risk Forecast Movement])

Kedar_Pande
Super User
Super User

@genaussie 

Create a Measure for Risk Forecast Movement:

RiskForecastMovement = 
VAR CurrentPeriod = MAX('Table'[Reporting Period])
VAR PreviousPeriod =
CALCULATE(
MAX('Table'[Reporting Period]),
FILTER(
ALL('Table'),
'Table'[Reporting Period] < CurrentPeriod
&& 'Table'[Project Number] = MAX('Table'[Project Number])
)
)
VAR CurrentForecast =
CALCULATE(
MAX('Table'[Risk Forecast]),
FILTER('Table', 'Table'[Reporting Period] = CurrentPeriod)
)
VAR PreviousForecast =
CALCULATE(
MAX('Table'[Risk Forecast]),
FILTER('Table', 'Table'[Reporting Period] = PreviousPeriod)
)
RETURN
IF(
NOT(ISBLANK(CurrentForecast)) && NOT(ISBLANK(PreviousForecast)),
IF(CurrentForecast > PreviousForecast, "Increase", "Decrease"),
BLANK()
)

Create a Measure to Check Reportable Flag

IsReportable = 
VAR CurrentPeriod = MAX('Table'[Reporting Period])
VAR PreviousPeriod =
CALCULATE(
MAX('Table'[Reporting Period]),
FILTER(
ALL('Table'),
'Table'[Reporting Period] < CurrentPeriod
&& 'Table'[Project Number] = MAX('Table'[Project Number])
)
)
VAR CurrentReportable =
CALCULATE(
MAX('Table'[Reportable Flag]),
FILTER('Table', 'Table'[Reporting Period] = CurrentPeriod)
)
VAR PreviousReportable =
CALCULATE(
MAX('Table'[Reportable Flag]),
FILTER('Table', 'Table'[Reporting Period] = PreviousPeriod)
)
RETURN
IF(CurrentReportable = "Yes" && PreviousReportable = "Yes", 1, 0)

Create a measure to use in the slicer or visual for filtering projects based on movement.

FilteredMovement = 
IF(
[IsReportable] = 1,
[RiskForecastMovement],
BLANK()
)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

genaussie
Frequent Visitor

@DataNinja777 thank you so much, I have verified this solution works and is an excellent solution 😊

DataNinja777
Super User
Super User

Hi @genaussie ,

 

To calculate the desired movement dynamically, we will use the following DAX measures:

  1. Measure for Current Period Risk Forecast:
Current Period Risk Forecast = 
CALCULATE(
    MAX('Table'[Risk Forecast]),
    FILTER(
        'Table',
        'Table'[Reporting Period] = SELECTEDVALUE('Table'[Reporting Period]) &&
        'Table'[Reportable Flag] = "Yes"
    )
)
  1. Measure for Previous Period Risk Forecast:
Previous Period Risk Forecast = 
CALCULATE(
    MAX('Table'[Risk Forecast]),
    FILTER(
        'Table',
        'Table'[Reporting Period] = EDATE(SELECTEDVALUE('Table'[Reporting Period]), -1) &&
        'Table'[Reportable Flag] = "Yes"
    )
)

3. Measure for Risk Forecast Movement:

 

Risk Forecast Movement Measure = 
VAR CurrentRisk = [Current Period Risk Forecast]
VAR PreviousRisk = [Previous Period Risk Forecast]
RETURN
    IF(
        ISBLANK(CurrentRisk) || ISBLANK(PreviousRisk),
        BLANK(),
        IF(
            CurrentRisk > PreviousRisk, 
            "Increase", 
            IF(
                CurrentRisk < PreviousRisk, 
                "Decrease", 
                "No Change"
            )
        )
    )

4. Measure for Filtering Projects Based on Slicer Selection:

Filtered Projects = 
VAR Movement = [Risk Forecast Movement Measure]
RETURN
    IF(
        Movement = SELECTEDVALUE('Slicer Table'[Movement]),
        1,
        0
    )

These measures dynamically calculate the movement based on the selected reporting period and ensure alignment between the current and previous periods. The Filtered Projects measure is applied as a visual-level filter set to = 1 in the table visual to filter projects based on the selected movement ("Increase" or "Decrease") in the slicer.

 

Best regards,

 

@DataNinja777 to confirm, is there another step (prior to step 4) where you are required to build a Disconnected Table, as per this post? The table should only have the options Increase/Decrease. This worked for me.

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.

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.