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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Guillermox
Regular Visitor

A measure that, based on the last 3 results of a table, place a description

Hello, I have a report that I pull into Power BI with this example information (the table on the left), and I would like to calculate (in a measure I assume) that if only the LAST 3 (#type) consecutive surveys (assigned with this type T1 until T6 but some classes can reach less than T6) and each one is greater than or equal to 85% the final result of the class puts me "Approved", otherwise I put "failed" (if one of the LAST 3 is less than ).

 

Class#TypeResult FINAL RESULT 
AT180% ClassMeasure
AT281% Aapproved
AT379% Yapproved
AT485% Znot approved
AT586%   
AT687%   
YT178%   
YT285%   
YT386%   
YT485%   
ZT186%   
ZT285%   
ZT385%   
ZT475%   
ZT586%   

 

last 3 of each class: A(T4,T5,T6), Y(T2,T3,T4), Z(T3,T4,T5)

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

try

Status measure =
IF (
    HASONEVALUE ( 'Table'[Class] ),
    VAR SummaryTable =
        TOPN ( 3, 'Table', 'Table'[#Type] )
    VAR NumPasses =
        COUNTROWS ( FILTER ( SummaryTable, 'Table'[Result] >= 0.85 ) )
    RETURN
        IF ( NumPasses = 3, "approved", "not approved" )
)

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

try

Status measure =
IF (
    HASONEVALUE ( 'Table'[Class] ),
    VAR SummaryTable =
        TOPN ( 3, 'Table', 'Table'[#Type] )
    VAR NumPasses =
        COUNTROWS ( FILTER ( SummaryTable, 'Table'[Result] >= 0.85 ) )
    RETURN
        IF ( NumPasses = 3, "approved", "not approved" )
)

Thanks @johnt75  this worked. Could you explain to me how each line works please? because I understand that TOPN takes the first 3, but in your solution I see that if it is taking the last 3. I am confused.

By default TOPN sorts in descending order, that's what its doing here.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.