Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
john_Talampas
Partner - Contributor II
Partner - Contributor II

Sum Distinct Value

Hello,

 

I have a request from a user to look at the "DATE" field, below, and to grab the total number of discharges that occurred 30 days prior.  

 

I'm able to build, into my data model, the discharges that occurred 30 days prior and group them into days:

Date - 30Discharges
12/9/2018253
12/22/2018273
12/30/2018253
1/1/2019273
 1,052

 

 

I am using the "DATE - 30" to tie the prior discharges to the current "DATE".

 

CalendarYearMonthDATEDATE - 30PlanTotal AcctDischarges -30 daysUnmatched Volume
2019-012019-01-08 00:00:00.0002018-12-09 00:00:00.000MINNESOTA GEN MCP M22530.8%
2019-012019-01-08 00:00:00.0002018-12-09 00:00:00.000MONTANA M22530.8%
2019-012019-01-08 00:00:00.0002018-12-09 00:00:00.000SOUTH DAKOTA M222538.7%
2019-012019-01-08 00:00:00.0002018-12-09 00:00:00.000NEBRASKA TC12530.4%
2019-012019-01-08 00:00:00.0002018-12-09 00:00:00.000NEBRASKA WC02530.0%
       
2019-012019-01-21 00:00:00.0002018-12-22 00:00:00.000SOUTH DAKOTA M42731.5%
       
2019-012019-01-29 00:00:00.0002018-12-30 00:00:00.000MONTANA M12530.4%
2019-012019-01-29 00:00:00.0002018-12-30 00:00:00.000SOUTH DAKOTA M52532.0%
2019-012019-01-29 00:00:00.0002018-12-30 00:00:00.000WYOMING M42531.6%
       
2019-012019-01-31 00:00:00.0002019-01-01 00:00:00.000DENVER HM CHO12730.4%
2019-012019-01-31 00:00:00.0002019-01-01 00:00:00.000WYOMING M12730.4%
   This is what I have435268.2%
       
       
   This is what I want4310524.1%

 

While this is fine I can not seem to calculate correctly the total number of discharges.  

So for "CalendarYearMonth" of 2019-01 I have 43 "Total Acct".  I'm trying to produce a calculation that will show the total distinct discharges of 1052; not the 526 that I currently have. 

Any insight on how to correctly calculate the total discharges will be greatly appreciated.

 

John T

 

 

1 Solution

Accepted Solutions
StarinieriG
Partner - Specialist
Partner - Specialist

Hi,

 

try in this way:

 

If(Dimensionality()=0,Sum(Aggr(Max([Discharges -30 days]),[DATE - 30])),your expr.)

View solution in original post

2 Replies
StarinieriG
Partner - Specialist
Partner - Specialist

Hi,

 

try in this way:

 

If(Dimensionality()=0,Sum(Aggr(Max([Discharges -30 days]),[DATE - 30])),your expr.)

john_Talampas
Partner - Contributor II
Partner - Contributor II
Author

That did the trick.  Thank you