How to Calculate the Number of Days Between Start and End Dates Using DATE_DIFF in Looker Studio

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2025

ความคิดเห็น • 6

  • @greenfox4606
    @greenfox4606 4 หลายเดือนก่อน +1

    Hello! Can you tell, please, how to count days of all report from Jun 1 to Jun 30 in your case.

    • @kp_playbook
      @kp_playbook  4 หลายเดือนก่อน

      If you set your date range from Jun 1 to Jun 30 and then use the DATE_DIFF(MAX(Day),MIN(Day)) calculated field shown in the video, that would count the number of days in that date range.

    • @greenfox4606
      @greenfox4606 4 หลายเดือนก่อน +1

      @@kp_playbook thank a lot for your replay! I'm going to count days of report, not days of data exist, so i need a correct name of field "report date".

    • @kp_playbook
      @kp_playbook  4 หลายเดือนก่อน

      @@greenfox4606 In that case, use a calculated field for the cost or whatever metric you're working with. The calculation is NARY_MAX(Your Metric,0) -- this forces every value to be zero even if it was null. That should do the trick.

  • @kristjanreinsberg7755
    @kristjanreinsberg7755 หลายเดือนก่อน

    Would it be possible to make score card that counts only working days between two dates?

    • @kp_playbook
      @kp_playbook  หลายเดือนก่อน

      Yes, try this as a calculated field:
      SUM(
      CASE
      WHEN EXTRACT(DAYOFWEEK FROM Date) IN (1,7) THEN 0
      ELSE 1
      END
      )
      That won't remove holidays, but it will return the number of weekdays.
      Let me know how that works out for you!