cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Maverick423 Frequent Visitor
Frequent 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
Super User

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

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 Frequent Visitor
Frequent 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
Super User

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 Frequent Visitor
Frequent 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 Frequent Visitor
Frequent 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
Super User

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
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 46 members 958 guests
Please welcome our newest community members: