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
wolfgang_voigt
Regular Visitor

Find the next row with earlier does not work with slicer

Hello guys,

I'm new to powerbi and I'm searching now already for hours for a (I think) easy problem.

 

I want to calculate a MTBF based on calls.

The calls can happen in different servicelines, which are filterable by a slicer.

 

I now simply want to display the time of the next call based on the selection in the slicer. In this screenshot everything is fine, as all categories are selected:

 

image.png

 

 

But if I now deselect one category the wrong date gets selected:

image.png

 

 

I'm using this code:

 

Next call = 
VAR NextRow = MINX(
	FILTER(
		ALLSELECTED(Events);
		Events[Time of call]>EARLIER(Events[Time of call];1)
	);
	Events[Time of call]
)
	
RETURN NextRow

I think the problem is, that the EARLIER function is not working when filtered with the slicer.

Can someone tell me how to fix this issue?

 

Thanks in advance!

 

Best regards

Wolfgang

3 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @wolfgang_voigt 

 

This is because calculated colun wont respond to slicer changes as calculated column values will be calculated once the data load is done and it will remain static. Please use the logic in measure.

 

Thanks

Raj

View solution in original post

v-cherch-msft
Employee
Employee

Hi @wolfgang_voigt 

 

You may create a measure to get dynamic value.For example:

Next call Measure = 
VAR NextRow = MINX(
	FILTER(
		ALLSELECTED(Events);
		Events[Time of call]>MAX(Events[Time of call])
	);
	Events[Time of call]
)
	
RETURN NextRow

Regards,

Cherie

Community Support Team _ Cherie Chen
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

I solved this on my own.

It was more easy than I thought:

 
Average MTBF in hours =
AVERAGEX(
    KEEPFILTERS(VALUES('Events'[Time of call]));
    CALCULATE([Uptime in hours])
)

View solution in original post

4 REPLIES 4
v-cherch-msft
Employee
Employee

Hi @wolfgang_voigt 

 

You may create a measure to get dynamic value.For example:

Next call Measure = 
VAR NextRow = MINX(
	FILTER(
		ALLSELECTED(Events);
		Events[Time of call]>MAX(Events[Time of call])
	);
	Events[Time of call]
)
	
RETURN NextRow

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @wolfgang_voigt 

 

This is because calculated colun wont respond to slicer changes as calculated column values will be calculated once the data load is done and it will remain static. Please use the logic in measure.

 

Thanks

Raj

Hi rajendran,

thanks for the hint didn't knew this behaviour and now it makes sense.

The reason I decided to use a coloumn was that I thought it would be more easy to calculate an average of that coloumn.

 

I now created the measure and try to find the average per category:

 

image.png

Uptime in hours = 
VAR NextRow =
    CALCULATE (
        MIN ( Events[Time of call] );
        FILTER (
            ALLSELECTED ( Events );
            Events[Time of call] > SELECTEDVALUE ( Events[Time of call] )
        )
    )	
VAR DDIFF = IF(ISBLANK(NextRow);
    Now() - SELECTEDVALUE ( Events[Time of call] );
    NextRow - SELECTEDVALUE ( Events[Time of call] )
)
RETURN int(DDIFF * 24)

The problem is, that I now don't have a coloumn and can not simply use the average function.

I guess I have to use AVERAGEX for that but it also requires a Table as Input and I don't get how I should select the measure here.

 

Maybe you can give a second tip here, I think this would help me alot!

 

Thanks!

 

-

Wolfgang

I solved this on my own.

It was more easy than I thought:

 
Average MTBF in hours =
AVERAGEX(
    KEEPFILTERS(VALUES('Events'[Time of call]));
    CALCULATE([Uptime in hours])
)

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.