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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
cmorrow
Frequent Visitor

"What if" parameters - An unexpected exception occurred

I have a scenario where we want to analyze vehicle usage during business hours vs non-business hours.  However, the user wants to be able to change the definition of "business hours" on the fly.  To accomplish this, I thought I'd try using "What if" parameters.

 

I've created 2 "What if" parameters:

Business Start Hour = GENERATESERIES(0, 23, 1)

Business End Hour = GENERATESERIES(0, 23, 1)

 

I then created a calculated column with the following function:

Hour Type =

IF( WEEKDAY(FactTable[ReadingTime],2) < 6 && HOUR(FactTable[ReadingTime]) >= 'Business Start Hour'[Business Start Hour Value] && HOUR(FactTable[ReadingTime]) < 'Business End Hour'[Business End Hour Value], "Regular Hours", "After Hours")

 

However, the DAX function errors with "An unexpected exception occurred" and PBI generates a dump file.  I've tried just using one of the parameters and hard-coding the other value, but I still get the same error.  Am I using the "What if" parameter incorrectly?  Maybe it's not meant to be used inside an IF condition?  

1 ACCEPTED SOLUTION

Hi @cmorrow ,

 

We can create two measures to work on it.

 

After Hours = CALCULATE(COUNTROWS(Table1),FILTER(Table1,[Measure]="After Hours"))
Regular Hours = CALCULATE(COUNTROWS(Table1),FILTER(Table1,[Measure]="Regular Hours"))

1.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

5 REPLIES 5
v-frfei-msft
Community Support
Community Support

Hi @cmorrow ,

 

We can create a measure to work on it instead of a calculated column.

 

Measure =
IF (
    WEEKDAY ( MAX ( 'Table1'[ReadingTime] ), 2 ) < 6
        && HOUR ( MAX ( 'Table1'[ReadingTime] ) )
            >= SELECTEDVALUE ( 'Business Start Hour'[Value] )
        && HOUR ( MAX ( 'Table1'[ReadingTime] ) )
            <= SELECTEDVALUE ( 'Business End Hour'[Value] ),
    "Regular Hours",
    "After Hours"
)

Capture.PNG

 

Also please find the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

@v-frfei-msft Unfortunately, I don't think a measure will work the way I need to use it (in a chart) like below.  And I think what it comes down to is what @Vvelarde said, that calculated columns are not dynamic.  That's disappointing, but at least it explains the error.  I'll have to find another way to do this.  Thank you both for your quick responses.

 

Capture.PNG

Hi @cmorrow ,

 

We can create two measures to work on it.

 

After Hours = CALCULATE(COUNTROWS(Table1),FILTER(Table1,[Measure]="After Hours"))
Regular Hours = CALCULATE(COUNTROWS(Table1),FILTER(Table1,[Measure]="Regular Hours"))

1.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @cmorrow ,

 

Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Vvelarde
Community Champion
Community Champion

@cmorrow 

 

Hi, 2 things to consider:

 

1. GenerateSeries Create a table in this case 0,1,2,3---23. To obtain the selection you can use SelectedValue.

 

2. A calculated column is not dynamic. So you can't modify with the Selected Value od the series. 

 

Regards

 

Victor




Lima - Peru

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.