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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
mmvohra
Helper II
Helper II

Converting calculated column into parameter

I have calculated column which is dependent on a measure. The measure itself is dependent on parameter. Now I want to convert the calculated column into measure form so that when the parameter updates "DaysInMarket" also gets updated. Suggest a solution please.


Calculated Column:
DaysInMarket =

VAR CurrentConsolidatedID = 'Work'[ConsolidatedID]

 

-- Earliest date for this ConsolidatedID

VAR First_Date =

    CALCULATE(

        MIN('Work'[Date]),

        'Work', 'Work'[ConsolidatedID] = CurrentConsolidatedID &&

        Repost Count ID check>0

)

 

-- Latest date for this ConsolidatedID

VAR Last_Date =

    CALCULATE(

        MAX('Work'[Date]),

       'Work', 'Work'[ConsolidatedID] = CurrentConsolidatedID &&

        Repost Count ID check >0

    )

 

RETURN

if ( 'Work'[Date]=Last_Date, DATEDIFF(First_Date, Last_Date, DAY),0)

Measure:

Repost Count ID check =

VAR Threshold = 'Parameter 2'[Parameter Value]

RETURN

 

CALCULATE(

    DISTINCTCOUNT('Work'[id]),

   

    FILTER(

       ALLEXCEPT('Work','Work'[ConsolidatedID]),

        VAR Previous_Date =

            CALCULATE(

                MIN('Work'[Date]),

                ALLEXCEPT('Work', 'Work'[ConsolidatedID])

            )

 

       

 

    VAR Initial_Mileage =

            CALCULATE(

                MIN('Work'[Mileage]),

                ALLEXCEPT('Work', 'Work'[ConsolidatedID]),

                'Work'[Date]= Previous_Date

            )

VAR BaselineID =

    CALCULATE(

        MIN('Work'[id]),

        ALLEXCEPT('Work','Work'[ConsolidatedID]),

        'Work'[Date] = Previous_Date

    )

 

VAR DIF= ABS('Work'[Mileage]-Initial_Mileage)

 

VAR Count_1=CALCULATE(COUNTROWS('Work'), ALLEXCEPT('Work','Work'[ConsolidatedID]))

 

RETURN

   DIF <= Threshold &&

    Count_1 > 1

   

    )  

)

1 ACCEPTED SOLUTION
mohit_sakhare
Resolver II
Resolver II

Hi,

A calculated column won’t react to a parameter change because it’s only evaluated at refresh time. To make DaysInMarket update dynamically when Parameter 2 changes, you need to convert it into a measure and compute First/Last dates using a row-level condition (based on the parameter), then return the value only for the “last date” row (same behavior as your column).

Here’s a working pattern:

1) Create a row-level pass/fail measure (parameter-driven):

Pass Threshold :=
VAR Threshold = SELECTEDVALUE('Parameter 2'[Parameter Value], 0)

VAR PrevDate =
CALCULATE(
MIN('Work'[Date]),
ALLEXCEPT('Work', 'Work'[ConsolidatedID])
)

VAR InitialMileage =
CALCULATE(
MIN('Work'[Mileage]),
ALLEXCEPT('Work', 'Work'[ConsolidatedID]),
'Work'[Date] = PrevDate
)

VAR CountRowsCID =
CALCULATE(
COUNTROWS('Work'),
ALLEXCEPT('Work', 'Work'[ConsolidatedID])
)

VAR Dif = ABS( MAX('Work'[Mileage]) - InitialMileage )

RETURN
IF( CountRowsCID > 1 && Dif <= Threshold, 1, 0 )

2) Replace the calculated column with this measure:

DaysInMarket :=
VAR CurrentDate = SELECTEDVALUE('Work'[Date])

VAR ValidRows =
FILTER(
ALLEXCEPT('Work', 'Work'[ConsolidatedID]),
[Pass Threshold] = 1
)

VAR FirstDate = MINX(ValidRows, 'Work'[Date])
VAR LastDate = MAXX(ValidRows, 'Work'[Date])

RETURN
IF(
NOT ISBLANK(CurrentDate) && CurrentDate = LastDate,
DATEDIFF(FirstDate, LastDate, DAY),
0
)

This will now recalculate dynamically whenever the DaysInMarket parameter/threshold changes. It works best in a table/matrix where Work[Date] is in the visual (so the measure can identify the “last date” row).

View solution in original post

3 REPLIES 3
v-echaithra
Community Support
Community Support

Hi @mmvohra ,

May I ask if you have resolved this issue? Please let us know if you have any further issues, we are happy to help.

Thank you.

v-echaithra
Community Support
Community Support

Hi @mmvohra ,

Thank you @mohit_sakhare   for the inputs.
We’d like to follow up regarding the recent concern. Kindly confirm whether the issue has been resolved, or if further assistance is still required. We are available to support you and are committed to helping you reach a resolution.

Thank you.

mohit_sakhare
Resolver II
Resolver II

Hi,

A calculated column won’t react to a parameter change because it’s only evaluated at refresh time. To make DaysInMarket update dynamically when Parameter 2 changes, you need to convert it into a measure and compute First/Last dates using a row-level condition (based on the parameter), then return the value only for the “last date” row (same behavior as your column).

Here’s a working pattern:

1) Create a row-level pass/fail measure (parameter-driven):

Pass Threshold :=
VAR Threshold = SELECTEDVALUE('Parameter 2'[Parameter Value], 0)

VAR PrevDate =
CALCULATE(
MIN('Work'[Date]),
ALLEXCEPT('Work', 'Work'[ConsolidatedID])
)

VAR InitialMileage =
CALCULATE(
MIN('Work'[Mileage]),
ALLEXCEPT('Work', 'Work'[ConsolidatedID]),
'Work'[Date] = PrevDate
)

VAR CountRowsCID =
CALCULATE(
COUNTROWS('Work'),
ALLEXCEPT('Work', 'Work'[ConsolidatedID])
)

VAR Dif = ABS( MAX('Work'[Mileage]) - InitialMileage )

RETURN
IF( CountRowsCID > 1 && Dif <= Threshold, 1, 0 )

2) Replace the calculated column with this measure:

DaysInMarket :=
VAR CurrentDate = SELECTEDVALUE('Work'[Date])

VAR ValidRows =
FILTER(
ALLEXCEPT('Work', 'Work'[ConsolidatedID]),
[Pass Threshold] = 1
)

VAR FirstDate = MINX(ValidRows, 'Work'[Date])
VAR LastDate = MAXX(ValidRows, 'Work'[Date])

RETURN
IF(
NOT ISBLANK(CurrentDate) && CurrentDate = LastDate,
DATEDIFF(FirstDate, LastDate, DAY),
0
)

This will now recalculate dynamically whenever the DaysInMarket parameter/threshold changes. It works best in a table/matrix where Work[Date] is in the visual (so the measure can identify the “last date” row).

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.