cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cmorrow Frequent Visitor
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

Accepted Solutions
Community Support Team
Community Support Team

Re: "What if" parameters - An unexpected exception occurred

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 other members find it more quickly.

View solution in original post

5 REPLIES 5
Vvelarde Super Contributor
Super Contributor

Re: "What if" parameters - An unexpected exception occurred

@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
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!




Community Support Team
Community Support Team

Re: "What if" parameters - An unexpected exception occurred

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 other members find it more quickly.
Highlighted
cmorrow Frequent Visitor
Frequent Visitor

Re: "What if" parameters - An unexpected exception occurred

@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

Community Support Team
Community Support Team

Re: "What if" parameters - An unexpected exception occurred

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 other members find it more quickly.

View solution in original post

Community Support Team
Community Support Team

Re: "What if" parameters - An unexpected exception occurred

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 other members find it more quickly.

Helpful resources

Announcements
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 168 members 1,944 guests
Please welcome our newest community members: