Forum Discussion
How com this two formula shows same result?!
Hi everyone,
Could anyone tell the differences of below formula:
- left month = sum('resignation'[noleft])
- quit = CALCULATE([no left],DATESBETWEEN(DatesTemplate[Date],[minday],[maxday])
The background is that i have a DATE filter on the report page, i could choose the start date and end date. And also:
no left = if(sum('resignation'[noleft])=BLANK(),0,sum('resignation'[noleft]))
I check time after time, and find there is NO DIFFERENCE between the upper formula "left month" and "quit". Am I correct? Thanks, every one.
HI thomaschen ,
My response is as follows:
- left month = sum('resignation'[noleft]) SUM function in Power BI adds all the numbers within a column. So, if there are any blanks it will ignore them and add up all the numeric non-blank values. This is what is happening here. It ends up with a single scalar value.
- no left = if(sum('resignation'[noleft])=BLANK(),0,sum('resignation'[noleft])) This folrmula is checking if any blanks are found output result as 0, else sum-up numeric values in your column. That's why again gives same result as adding up 0's to a numeric value doesn't create difference.
- quit = CALCULATE([no left],DATESBETWEEN(DatesTemplate[Date],[minday],[maxday]) This formula uses your above calculation which is exact in output as per your 1st calculation. The difference here is just you have a filter for startDate and endDate. Your current filter shows STARTDATE = MINDATE in data and ENDDATE = MAXDATE in data; which is basically taking your whole data into consideration.
Thanks,
Pragati
thanks a lot for quick answer.đ
this formula ăno left = if(sum('resignation'[noleft])=BLANK(),0,sum('resignation'[noleft])) ă is just show as a background.
one more confusion, when I change the date filter( like the start date or end date) on my report page, both of the result 1st formula ăleft monthă and the 3rd formulaăquităshows same result. Will it in any scenario, that two formulas will show different results?
Hi thomaschen ,
The 2 formulas show same result when you modify your date slicers. The reason is that both of your DAX calculations are getting affected by external filters. They will now show same result if you modify one of your calculations to dis-allow external filters.
You can check ALL, ALLSELECTED, KEEPFILTERS dax functions in Power BI to create differences in your calculations.
Thanks,
Pragati
OH, I understand now.
there will be differences shows when use the ăleft monthăorăquităin a chart with DATE as the Y-Axis.
1. when using ăleft monthă, the chart will show a monthly result.
2. when using the ăquităďźtha chat will show an accumulated result.
đ
4 Replies
- Pragati11Super User
HI thomaschen ,
My response is as follows:
- left month = sum('resignation'[noleft]) SUM function in Power BI adds all the numbers within a column. So, if there are any blanks it will ignore them and add up all the numeric non-blank values. This is what is happening here. It ends up with a single scalar value.
- no left = if(sum('resignation'[noleft])=BLANK(),0,sum('resignation'[noleft])) This folrmula is checking if any blanks are found output result as 0, else sum-up numeric values in your column. That's why again gives same result as adding up 0's to a numeric value doesn't create difference.
- quit = CALCULATE([no left],DATESBETWEEN(DatesTemplate[Date],[minday],[maxday]) This formula uses your above calculation which is exact in output as per your 1st calculation. The difference here is just you have a filter for startDate and endDate. Your current filter shows STARTDATE = MINDATE in data and ENDDATE = MAXDATE in data; which is basically taking your whole data into consideration.
Thanks,
Pragati
- thomaschenNew Member
thanks a lot for quick answer.đ
this formula ăno left = if(sum('resignation'[noleft])=BLANK(),0,sum('resignation'[noleft])) ă is just show as a background.
one more confusion, when I change the date filter( like the start date or end date) on my report page, both of the result 1st formula ăleft monthă and the 3rd formulaăquităshows same result. Will it in any scenario, that two formulas will show different results?
- Pragati11Super User
Hi thomaschen ,
The 2 formulas show same result when you modify your date slicers. The reason is that both of your DAX calculations are getting affected by external filters. They will now show same result if you modify one of your calculations to dis-allow external filters.
You can check ALL, ALLSELECTED, KEEPFILTERS dax functions in Power BI to create differences in your calculations.
Thanks,
Pragati