cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
imoreno
Frequent Visitor

Remove Row context without removing Filter Context

Hello,

 

Hope someone can help.

 

I have:

 

- the next table:

 

StepResultDateBuild
1Failed10/02/2021A
1Failed10/03/2021B
1Passed11/03/2021B
2Failed12/03/2021B
2Failed12/03/2021B
2Passed10/04/2021C
3Passed13/04/2021C
3Failed10/04/2021C
4Failed11/02/2021A
5Passed15/02/2021A
5Passed10/03/2021B
5Failed10/04/2021C
5Failed12/04/2021C
6Passed10/03/2021B
7Passed12/02/2021A
7Failed10/03/2021B
7Failed14/03/2021B
7Failed16/03/2021B
7Passed10/04/2021C
8Passed14/04/2021C
8Failed16/04/2021C
8Failed17/04/2021C
8Passed18/04/2021C
9Passed10/02/2021A
9Failed15/02/2021A
9Failed18/02/2021A
9Passed11/03/2021B
9Passed14/03/2021B
9Failed10/04/2021C

 

- A slicer with multiselection on Build field.

 

My goal is to obtain a measure that calculate the last date for a specific step given the slicer selection.

 

I'm trying with:

 

Last Date = CALCULATE(MAX(Executions[Fecha]), ALLEXCEPT(Executions, Executions[Paso]), VALUES(Executions[Build]))
 
My problem is that VALUES(Executions[Build]) is getting not only the slicer selection, but the row context too.
 
E.g. selecting in the build slicer A and B i obtain for step 1:
 
StepDateLast DateBuildResult
110/02/2021 0:0010/02/2021 0:00AFailed
111/03/2021 0:0011/03/2021 0:00BPassed
110/03/2021 0:0011/03/2021 0:00BFailed

 

When I was waiting:

 

StepDateLast DateBuildResult
110/02/2021 0:0011/03/2021 0:00AFailed
111/03/2021 0:0011/03/2021 0:00BPassed
110/03/2021 0:0011/03/2021 0:00BFailed

 

How can i remove the row context without removing the filter context?

 

Thanks a lot

 

Iván

 

2 ACCEPTED SOLUTIONS
ERD
Solution Sage
Solution Sage

Hi @imoreno ,

Please, try the next measure:

latestDate =
VAR currStep = MAX ( T[Step] )
RETURN
    CALCULATE (
        MAX ( T[Date] ),
        FILTER ( ALLSELECTED ( T ), T[Step] = currStep )
    )

ERD_0-1623662373843.png

 

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

ERD
Solution Sage
Solution Sage

@imoreno ,

You can try this measure instead:

count = 
VAR _t =
    FILTER (
        ADDCOLUMNS (
            SUMMARIZE ( T, T[Step], T[Result], T[Build] ),
            "@check",
                VAR maxDatePerStep =
                    CALCULATE ( MAX ( T[Date] ), ALLEXCEPT ( T, T[Step], T[Build] ) )
                VAR maxDatePerResult =
                    CALCULATE ( MAX ( T[Date] ) )
                RETURN
                    maxDatePerStep = maxDatePerResult
        ),
        [@check] = TRUE ()
    )
RETURN
    COUNTROWS ( _t )

ERD_0-1623739220528.png

 

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

4 REPLIES 4
imoreno
Frequent Visitor

Great!!

 

Thank you very much. I've mixed both answers, in order to be able to select more than one build, and it's working perfectly.

 

Best regards

 

Iván

imoreno
Frequent Visitor

Thank you very much, ERD. 


It works. I hadn't understood properly the ALLSELECTED context behaviour.

 

Now i have another context problem:

 

My goal with this date is to have a measure for counting PASSED / FAILED results, taking into account only the last execution of the selected builds.

 

I have a new boolean measure which is:

 

[Last Result] = [Max Date] = [Last Date]

 

where Max Date = MAX(Executions[Fecha])

 

It's working ok at row context level.

 

But when I'm trying to count all the rows on a context with Last Result = TRUE, the context is not taking the Last Date measure properly (or the Max Date or both).

 

E.g.: With:

 

Last Result Count = CALCULATE(COUNTROWS(Executions), FILTER(Executions, [Last Result]))
 
I obtain for A build 3 FAILED and 3 PASSED, when it should be 3 FAILED and 2 PASSED.  Moreover, in the previous table, all the rows display Last Result Count as 1, when no all of them have Last Result = True.
 
I've trying with:
 
Last Result Count = COUNTROWS(CALCULATETABLE(Executions, FILTER(Executions, Executions[Date] = [Last Date])))

And it's the same result. Also with SUMX...

I'm trying to understand the context properly, but there is something that i'm missing.

Thank you again.

Best regards

ERD
Solution Sage
Solution Sage

@imoreno ,

You can try this measure instead:

count = 
VAR _t =
    FILTER (
        ADDCOLUMNS (
            SUMMARIZE ( T, T[Step], T[Result], T[Build] ),
            "@check",
                VAR maxDatePerStep =
                    CALCULATE ( MAX ( T[Date] ), ALLEXCEPT ( T, T[Step], T[Build] ) )
                VAR maxDatePerResult =
                    CALCULATE ( MAX ( T[Date] ) )
                RETURN
                    maxDatePerStep = maxDatePerResult
        ),
        [@check] = TRUE ()
    )
RETURN
    COUNTROWS ( _t )

ERD_0-1623739220528.png

 

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

ERD
Solution Sage
Solution Sage

Hi @imoreno ,

Please, try the next measure:

latestDate =
VAR currStep = MAX ( T[Step] )
RETURN
    CALCULATE (
        MAX ( T[Date] ),
        FILTER ( ALLSELECTED ( T ), T[Step] = currStep )
    )

ERD_0-1623662373843.png

 

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

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.