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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Convert a Column to a measure

Hi there

 

I'm wondering if there is some advice out there for turning this caculated column into a measure. I want to do this because my current set up causes for a really really slow process time. 

 

The intention of the column is to sum up the number of business days between the start and finish dates at a record level. 

Depending on that result the record either passes or fails expectations. 

 

Business Day Count = 
CALCULATE(
SUM(Date_Dim[BusinessDayFlag]),//this is an integer returning a 1 for true

FILTER( //filter intends to only count days between to and from
Dim_Date,
Dim_Date[Date] >=Fact_Records[RecordFromDate] 
&& Dim_Date[Date] <=Fact_Records[RecordToDate] 
)
)

My attempt at making this a measure hasn't come through with the performance result. this was my attempt

Business Day Count M = CALCULATE(
SUM(Dim_Date[BusinessDayFlag]),
FILTER(
ALL(Dim_Date),
(
    ( 
Dim_Date[FullDate] >= MIN(Fact_records[RecordFromDate])) 

&& (Dim_Date[FullDate] <= MAX(Fact_records[RecordToDate])
)
)))

 

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous

You could write variable inside a measure instead of using nested measure formula

Also, not using Filter could be better for performance.

This article provides a good explaination of using Filter vs not using Filter: https://powerpivotpro.com/2010/04/quick-tip-dont-over-use-filter/

Business Day Count M = 
VAR mins= MIN(Fact_Records[RecordFromDate])
VAR maxs= MAX(Fact_Records[RecordFromDate])
RETURN
CALCULATE(
SUM(Date_Dim[BusinessDayFlag]),
ALL(Date_Dim),
Date_Dim[Date] >=mins
&& Date_Dim[Date] <=maxs
)

Best Regards

Maggie

View solution in original post

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @Anonymous

You could write variable inside a measure instead of using nested measure formula

Also, not using Filter could be better for performance.

This article provides a good explaination of using Filter vs not using Filter: https://powerpivotpro.com/2010/04/quick-tip-dont-over-use-filter/

Business Day Count M = 
VAR mins= MIN(Fact_Records[RecordFromDate])
VAR maxs= MAX(Fact_Records[RecordFromDate])
RETURN
CALCULATE(
SUM(Date_Dim[BusinessDayFlag]),
ALL(Date_Dim),
Date_Dim[Date] >=mins
&& Date_Dim[Date] <=maxs
)

Best Regards

Maggie

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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