In this case, “ISINSCOPE()” function doesn’t have anything to do with fixing the grand totals. This function checks the validity of the condition at each line item level whether it satifies or not i.e., whether “Campaigns[BC #]” exists at line item level or not and provides the results accordingly.
Since you’re putting two fields inside the table visual i.e., “Campaign ID” and “BC #” but inside the measure only “BC #” is considered in the form of “VALUES( Campaigns[BC #] )”. This would’ve been true, only if you’re putting that single field inside the table visual and then evaluating the totals. But in this case, since you’re considering more than one field then context also needs to be adjusted in accordance with that. Below is the revised measure alongwith the screenshot of the final results provided for the reference -
Avg $ RIGHT Total Amount - Harsh =
IF( ISINSCOPE( Campaigns[Campaign ID] ) ,
[Avg $ Global OR Potential] ,
SUMX(
ADDCOLUMNS(
SUMMARIZE(
Campaigns ,
Campaigns[Campaign ID] ,
Campaigns[BC #] ) ,
"@Totals" ,
[Avg $ Global OR Potential] ) ,
[@Totals] ) )
Thanks Harsh. I understand the context now. Great explanation.
I come from an excel background, is there a tool where you can analyze a formula step by step. In excel, you can do this Evaluate Formula tool. Is a there a tool where I can do a step through an analysis to get better understanding of how it works.
There is a hidden gem in the August 2022 release of Power BI Desktop: a secret new DAX function EvaluateAndLog that is not listed in the feature summary of the official blogpost. Yet this function will become a great learning and debugging tool for anyone who writes DAX code in the years to come.
Read the 3 blogposts written by the tool author to follow instructions. Hope this helps!