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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Kcloud
Helper I
Helper I

Measure to return rows based on column conditions

Hi All,

 

I am trying to retrieve / filter rows in a report based on a where clause.

The scenario is that each quote (Id) will have an Estimate and when work has been done, will have a Final.

Each Id can additionally have multiple types based on the Rate (Work carried out during Day rates or Night Rates)

 

I want to be able to filter for a report and retrieve the rows where the Type is Final if the Id has a Final, or retrieve Estimate where it doesn't.

 

My imported data looks like this:

PBI1.png

 

What I want to display in my report:

 

PBI2.png

 

1 ACCEPTED SOLUTION

Hi @Kcloud ,

 

I create a sample to have a test. My sample is the same like yours.

RicoZhou_0-1650954412288.png

Measure:

Filter Measure = 
VAR _Type_List =
    CALCULATETABLE (
        VALUES ( 'Table'[Type] ),
        ALLEXCEPT ( 'Table', 'Table'[QuoteId] )
    )
RETURN
    IF (
        "Final" IN _Type_List,
        IF ( MAX ( 'Table'[Type] ) = "Final", 1 ),
        IF ( MAX ( 'Table'[Type] ) = "Estimated", 1 )
    )

Create a table visual , add this measure into visual level filter and set it to show items when value =1.

Result is as below.

RicoZhou_1-1650954486076.png

 

Best Regards,
Rico Zhou

 

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

3 REPLIES 3
amitchandak
Super User
Super User

@Kcloud , Use this measure as visual level filter


countx(filter(summarize(Table, Table[QuoteID], Table[Type], "_1", countx(filter(allselected(Table), Table[ID], max(Table[ID]) && Type = "Final")),, "_2", countx(filter(allselected(Table), Table[ID], max(Table[ID]) && Type = "Estimated"))), (not(Isblank(_1)) && [Type] ="Final") || ((Isblank(_1)) && [Type] ="Estimated")), [QuoteID])

 

check for not blank. Else create all measure using this code

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Unfortunately I am receiving this error when using that measure as a filter:

Error.png

Hi @Kcloud ,

 

I create a sample to have a test. My sample is the same like yours.

RicoZhou_0-1650954412288.png

Measure:

Filter Measure = 
VAR _Type_List =
    CALCULATETABLE (
        VALUES ( 'Table'[Type] ),
        ALLEXCEPT ( 'Table', 'Table'[QuoteId] )
    )
RETURN
    IF (
        "Final" IN _Type_List,
        IF ( MAX ( 'Table'[Type] ) = "Final", 1 ),
        IF ( MAX ( 'Table'[Type] ) = "Estimated", 1 )
    )

Create a table visual , add this measure into visual level filter and set it to show items when value =1.

Result is as below.

RicoZhou_1-1650954486076.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.