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

Retrieve just one quote

Hello PBI Experts,

In my report, I have a table that should contain selected fields from Opportunity and Quotes. I need to retrieve just one or the first quote linked to an entity considering that Opportunity to Quotes has 1->M relationship. How do I filter the Quotes so that my table would only contain one QUOTE linked to an Opportunity?

 

Regards,

Maverick423

 

 

 

1 ACCEPTED SOLUTION

Hi @Maverick423 

 

You can create a Measure like below, and use it later as Filters in your Table visual.

Measure = 
VAR _firstQuoteID = { CALCULATE( MAX( Quotes[qtID] ), ALL( Quotes[qtID] ) ) }
RETURN 
CALCULATE(
    COUNTROWS( Quotes ), 
    KEEPFILTERS( TREATAS( _firstQuoteID, Quotes[qtID] ) ) 
)

The attached file contains an applied solution.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski


 

 

 

View solution in original post

6 REPLIES 6
Mariusz
Community Champion
Community Champion

Hi @Maverick423 

 

Can You create a sample of your data.

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

Hello Mariusz,

Please see below for my test data in a table:

 

Capture.JPG

As you can see, I have here two Quotes under 1 Opportunity. The requirement is just to diplay the first Quote if there are 2 or more Quotes linked to an Opportunity. Is it possible to do it using DAX?

 

Regards,

Maverick423

Hi @Maverick423 

 

You can create a Measure like below, and use it later as Filters in your Table visual.

Measure = 
VAR _firstQuoteID = { CALCULATE( MAX( Quotes[qtID] ), ALL( Quotes[qtID] ) ) }
RETURN 
CALCULATE(
    COUNTROWS( Quotes ), 
    KEEPFILTERS( TREATAS( _firstQuoteID, Quotes[qtID] ) ) 
)

The attached file contains an applied solution.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski


 

 

 

Hi @Mariusz,

Just an additional question for this. When I tried to add more fields in the table like Opp Name and Quote Name, the visual filter will stop working. I tried to replicate the Measure using Opp Name and Quote Name but they did not work.

Thanks again.

 

Regards,

Maverick423

Hi @Maverick423 

 

The adjusted version should work, please see the below code and the attached file.

The problem was that the Quote Name column was not included in the ALL() statement and the filter context was still applied. 

Measure = 
VAR _firstQuoteID = { 
    CALCULATE( 
        MAX( Quotes[qtID] ), 
        ALL( Quotes ), 
        VALUES( Quotes[OppID] ) 
    ) 
}
RETURN 
CALCULATE(
    COUNTROWS( Quotes ), 
    KEEPFILTERS( TREATAS( _firstQuoteID, Quotes[qtID] ) ) 
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Hi @Mariusz,

Thank you ever so much for this. You're a genius!!

It solved my problem instantly:)

Regards,

Maverick423

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.