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
Jorritster
Frequent Visitor

Context issue when adding measure to a table

Hi all,

 

I am creating a model in which I check whether our customers have reached a particular Threshold in a particular country. If this happens we have to report for them more extensively. Therefore, I created the following measure:

 

Threshold_Passed =

IF([YTD_TaxableBasis] > 0

, IF([YTD_TaxableBasis] > SUM('Thresholds'[Threshold]), TRUE, FALSE)

, BLANK()

)

 

However, when I add this measure to a table it does not give me the expected output. In the first table you see that adding the measure makes the table retrieve a row for each combination of Direction, Year, Month, Customer, Entity and Country. In the second table you see that without the added Threshold_Passed measure just the country that is in scope is retrieved (in this case the Netherlands). For the other countries there is no data in the database for this customer, so I do not want to see the additional rows which are empty anyways. Besides that, the measure also does not understand my nested if statement (it returns false when the YTD_TaxableBasis is empty). I have checked my relationships and for me they all make sense. Also, the filter context understands that for Tesla only the Netherlands is in scope.

 

Jorritster_0-1658997632926.png

 

Expected output:

I want to see the second table with an additional column called Threshold_Passed where it gives back False for the first three rows and from April onwards returns True (as YTD_TaxableBasis is higher than the Threshold). 

 

Complete sample including relationships:

https://www.dropbox.com/s/cw681n31pytcngj/Dummy_Threshold_Management%20V2.pbix?dl=0

 

Any help or feedback is highly appreciated, as I am really stuck on this. If you need any further information, please let me know.

 

Kind Regards, Jorrit

1 ACCEPTED SOLUTION

Hi @Jorritster ,

I updated the sample pbix file provided by @tamerj1 (see attachment), please check if that is what you want...

1. Change the cross filter direction as Both

yingyinr_0-1659518005248.png

2. Update the formula of measure [Threshold_Passed] as below

Threshold_Passed =
VAR YTDTaxable =
[YTD_TaxableBasis]
VAR Threshold =
CALCULATE (
SUM ( 'Thresholds'[Threshold] ),
FILTER('CDM','CDM'[Direction]=SELECTEDVALUE('Direction'[Direction]))   // CROSSFILTER ( CDM[Direction], Direction[Direction], BOTH )
)
VAR Result =
IF (
YTDTaxable > Threshold,
"TRUE",
IF (
NOT ISBLANK ( Threshold ),
"FALSE"
)
)
RETURN
Result

yingyinr_1-1659518132269.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

Hi @Jorritster 
Here is the sample file with the solution https://we.tl/t-Uz6k0eE0dC

1.png2.png

Hi @tamerj1 ,

 

That is exactly what I wanted. I will accept it as a solution. However, I have one additional question. As we now change the two-directional filter between contract and country to one-directional, we lose the filter context. 

 

In my own model when I select a particular entity, I still get all the EU-countries to choose from in the country filter. Although, I preferably only see the countries that are contracted for that entity. 

 

Is that still possible or should I accept this little drawback?

Hi @Jorritster ,

Please try to set the option Cross filter join as Both just like in below screenshot, later check if the visual can display your expected result...

yingyinr_0-1659431811636.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yiruan-msft,

 

Thanks for your help. I did try this but it creates ambiguity for the Threshold_Passed measure @tamerj1 specified above because of the cross filter:

Jorritster_0-1659432237628.png

 

Is there a solution for this?

 

@Jorritster 

It is working just fine in the sample file I've shared on my previous reply. Please make sure to adjust the relationships as advised. 

@tamerj1 Actually it does not:

Jorritster_0-1659441800925.png

As you can see it displays multiple countries, while in the contract table only the NL is in scope. So ideally I would love to see just NL in this country slicer in this scenario. Is this possible?

 

Hi @Jorritster ,

I updated the sample pbix file provided by @tamerj1 (see attachment), please check if that is what you want...

1. Change the cross filter direction as Both

yingyinr_0-1659518005248.png

2. Update the formula of measure [Threshold_Passed] as below

Threshold_Passed =
VAR YTDTaxable =
[YTD_TaxableBasis]
VAR Threshold =
CALCULATE (
SUM ( 'Thresholds'[Threshold] ),
FILTER('CDM','CDM'[Direction]=SELECTEDVALUE('Direction'[Direction]))   // CROSSFILTER ( CDM[Direction], Direction[Direction], BOTH )
)
VAR Result =
IF (
YTDTaxable > Threshold,
"TRUE",
IF (
NOT ISBLANK ( Threshold ),
"FALSE"
)
)
RETURN
Result

yingyinr_1-1659518132269.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

Top Solution Authors