Forum Discussion
Measure
- 7 months ago
Hi HARSUE,
Thank you for the response. I request you to please provide the detailed solution so that it will be helpful for the other community members who has similar issue and you can accept that post as solution.
Click on the three dots at the top right of the reply and there is an option for "Accept as Solution" click on that.
Thanks and regards,
Anjan Kumar Chippa
Hi HARSUE , you are very close.
USERELATIONSHIP activates an inactive relationship, but it does not deactivate any active relationships.
So, if you currently have an active relationship between Date and FCT_Orders (by OrderDate) and you use USERELATIONSHIP to also relate Date to FCT_Offertes[StartDatum], then:
Date will filter both FCT_Orders by OrderDate and FCT_Offertes by StartDatum.
Through the active OfferteNr relationship, FCT_Offertes then filters FCT_Orders as well.
Assuming your active relationship is between 'Date'[Date] and FCT_Orders[OrderDate] (replace OrderDate with your actual date column), you can explicitly disable that relationship inside the measure:
Orderbedrag uit offertes :=
CALCULATE(
SUM ( FCT_Orders[Bedrag_Excl_BTW] ),
FCT_Orders[OfferteNr] <> BLANK(),
FCT_Orders[Artikelgroep] > 99,
-- Use the Date -> Offertes relationship for the quotation date
USERELATIONSHIP ( 'Date'[Date], FCT_Offertes[StartDatum] ),
-- Disable the Date -> Orders relationship for this calculation
CROSSFILTER ( 'Date'[Date], FCT_Orders[OrderDate], NONE )
)
If your table visual is already built on FCT_Offertes (and the Date table is related to FCT_Offertes[StartDatum]), you can also drive the filter from the quotations directly, using VALUES and TREATAS.
Example:
Orderbedrag uit offertes :=
VAR QuotesInContext =
VALUES ( FCT_Offertes[OfferteNr] )
RETURN
CALCULATE(
SUM ( FCT_Orders[Bedrag_Excl_BTW] ),
FCT_Orders[OfferteNr] <> BLANK(),
FCT_Orders[Artikelgroep] > 99,
-- Keep only orders that belong to the quotations in the current context
TREATAS ( QuotesInContext, FCT_Orders[OfferteNr] )
)
If this response was helpful in any way, I’d gladly accept a much like the joy of seeing a DAX measure work first time without needing another FILTER.
Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop .
Hello Zanqueta
Thanks for the extensive expanation.
The first measure results in a very high amount. (I guess these are all the orders resulting out of an order for the whole database.
The second measure has no value (empty)