Forum Discussion

thomaschen's avatar
thomaschen
New Member
6 years ago
Solved

How com this two formula shows same result?!

Hi everyone, 

 

Could anyone tell the differences of below formula:

  1. left month = sum('resignation'[noleft])
  2. 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:

    1. 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.
    2. 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.
    3. 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?   

  • Pragati11's avatar
    Pragati11
    6 years ago

    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

  • thomaschen's avatar
    thomaschen
    6 years ago

    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

  • HI thomaschen ,

     

    My response is as follows:

    1. 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.
    2. 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.
    3. 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

    • thomaschen's avatar
      thomaschen
      New 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?   

      • Pragati11's avatar
        Pragati11
        Super 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