Count Number of Log Ins this Year (2019)
I would like to create an insight card that divides the number of Last Logins in 2019 (125) against my total users (214) to show total percentage of users this year (58%). I am attempting to show this through a chart type of Progress Bar, Filled or Compartive Gauge (any suggestions appreciated).
However before I can create this, I need to use Beast Mode to adjust the Last Login column which is a date field that goes back to 2016. I need a formula that can count the Last Login dates that have a year of 2019.
I have tried in Beast Mode both a statement and a case, and neither is working.
COUNT(`Last Login`, YEAR(2019))
(CASE when `Last Login`>= YEAR(2019) then COUNT(`Last Login`) end)
Any ideas how I can get it to count the 2019 dates? Thanks.
The case statement approach makes sense to me. That said, let me recommend a couple of changes.
First, the case statement operates at the row level. What you want to do is determine which rows pertain to 2019, and then count those. Therefore, you want the count() outside the case. Second, the year() function operates by returing the year portion of an inputted date. Making adjustments for those two things, try something like this:
COUNT(CASE WHEN YEAR(`Last Login`) = 2019 THEN `Last Login` END)
I hope that works for you.
You could also make the year logic dynamic such that it always returns the last login for the current year. That way, you wouldn't need to change your logic when year 2020 rolls around. If that is of interest, check out the current_date() function.
This worked! Brilliant. Thank you!
Also, I took your suggestion and used the current date. For anyone who is reading this post, the solution for me was:
COUNT(case when YEAR(`Last Login`) = year(CURRENT_DATE()) then `Last Login` end)
I used the Progress Bar chart type and got the results needed.0
- 7.6K All Categories
- 913 Connectors
- 241 Workbench
- 470 Transform
- 1.8K Magic ETL
- 60 SQL DataFlows
- 445 Datasets
- 24 Visualize
- 194 Beast Mode
- 2K Charting
- 6 Variables
- 14 Cards, Dashboards, Stories
- 1 Automate
- 348 APIs & Domo Developer
- 82 Apps
- 14 Predict
- 3 Jupyter Workspaces
- 11 R & Python Tiles
- 241 Distribute
- 59 Domo Everywhere
- 241 Scheduled Reports
- 14 Manage
- 35 Governance & Security
- 18 Product Ideas
- 1.1K Ideas Exchange
- Community Forums
- 15 Getting Started
- 1 Community Member Introductions
- 49 Community News
- 18 Event Recordings
- 579 日本支部