I created a Datediff measure with conditional if statement, see image #1, that works like a charm but it doesn’t add the total when I put the measure in a table, see image #2, there is no total. What can i do in the measure so the total can be visible.
In order to achieve the results based on the scenario that you’ve specified. Below is the measure alongwith the screenshot of the final results provided for the reference -
$ HubSpot Campaign RFP - Harsh =
VAR _Start_Day = 0
VAR _End_Day = 548
VAR _Date_Range_Condition =
FILTER( Deal ,
DATEDIFF( Deal[RFP Received Date] , Deal[Campaign Member Create Date] , DAY ) >= _Start_Day &&
DATEDIFF( Deal[RFP Received Date] , Deal[Campaign Member Create Date] , DAY ) <= _End_Day )
VAR _Results =
CALCULATE( SUM( Deal[RFP Amount] ) ,
_Date_Range_Condition )
RETURN
_Results
In old measure, you had stated the condition as - “If date range is in between 0 and 548 then provide the results of RFP Amount or else 0”.
So what it actually did is, it provided you with the correct results at an individual line item level but at a grand total level since there was no presence of any context, it evaluated the results as 0. And that’s why, it didn’t provided the overall summation of results at a grand total level.
Similarly, you could have achieved the same results by creating a measure in order to fix the totals. Below is the measure provided for the reference -
But what I did is, removed that IF statement since in this particular scenario, it was not required and substituted that same condition or logic inside the Filter function as an expression.
I’m providing few links below for the reference purposes where similar type of queries were raised in the past by the members on our forum and how the “IF()” function works when it’s context is misunderstood.
I wanted to get the average RFP Influence time so I used your example of Fix Totals and it works perfectly but how can I modify to exclude negative values?
Average Influence Time for Total = //includes negative values
AVERAGEX(
ADDCOLUMNS(
SUMMARIZE(
Deal,
Deal[Yuhanna’s Campaign Test],
Deal[Deal Name]),
“@Averages”,
[RFP Influence TIME]),
[@Averages])
Based on the measure that you’ve provided, I evaluated the results and exported them into an Excel file and nowhere I was able to see any negative values. The starting value that I see is itself from postive 1. Below is the screenshot provided for the reference -