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.
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
Solved! Go to 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.
Hello Mariusz,
Please see below for my test data in a table:
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.
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] ) ) )
Hi @Mariusz,
Thank you ever so much for this. You're a genius!!
It solved my problem instantly:)
Regards,
Maverick423
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |