cancel
Showing results for 
Search instead for 
Did you mean: 
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

Accepted Solutions
Super User IV
Super User IV

Re: Retrieve just one quote

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
Super User IV
Super User IV

Re: Retrieve just one quote

Hi @Maverick423 

 

Can You create a sample of your data.

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

Maverick423
Regular Visitor

Re: Retrieve just one quote

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

Super User IV
Super User IV

Re: Retrieve just one quote

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

Maverick423
Regular Visitor

Re: Retrieve just one quote

Hi @Mariusz,

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

It solved my problem instantly:)

Regards,

Maverick423

Maverick423
Regular Visitor

Re: Retrieve just one quote

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

Super User IV
Super User IV

Re: Retrieve just one quote

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

 

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors