Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
hasmyt
Contributor II

Counting the no. of Days

Hello Everyone, 

I have a field which contains target values corresponding to months like for example:

Month    Target

Jan          100

Feb           200

 

I want to divide this target by no. of days to get day wise target.

 

For example in Feb, I want to divide 200 by 28. 

 

How can I do it? 

Labels (1)
2 Solutions

Accepted Solutions
justISO
Specialist

Hi, it depends a bit of how your Month field are made, because if it coming from date field, you can simply take days from end of month:

sum(Target) / day(monthend([date field]))

If you only have Month name, you need incorporate conversion from month name to date first, with something like this:

MakeDate(2022, Num(Month(Date#([Month field], 'MMMM'))), 1)

and insert that as [date field] in first formula.

View solution in original post

justISO
Specialist

Are you going to calculate that in report level or in load script? Because there are, again, multiple ways. If you calculate this target-per-day in report, suggested solution should work. If you want that in load, depends on your data model structure, you can merge those tables into one and calculate that target-per-day, or you can make new 'temporal' table, with month and target, calculate target-per-day and then join to one of your main tables (and drop that temp table as not needed).

View solution in original post

4 Replies
justISO
Specialist

Hi, it depends a bit of how your Month field are made, because if it coming from date field, you can simply take days from end of month:

sum(Target) / day(monthend([date field]))

If you only have Month name, you need incorporate conversion from month name to date first, with something like this:

MakeDate(2022, Num(Month(Date#([Month field], 'MMMM'))), 1)

and insert that as [date field] in first formula.

hasmyt
Contributor II
Author

Got it. But I have date field coming from one table and the target field coming from another, so how do I go about it?

justISO
Specialist

Are you going to calculate that in report level or in load script? Because there are, again, multiple ways. If you calculate this target-per-day in report, suggested solution should work. If you want that in load, depends on your data model structure, you can merge those tables into one and calculate that target-per-day, or you can make new 'temporal' table, with month and target, calculate target-per-day and then join to one of your main tables (and drop that temp table as not needed).

hasmyt
Contributor II
Author

Worked perfectly. Thank you.