I have a table with records of students' leaves with 12 columns for every month of the year and one row for each student.
Each cell keeps the records of the student's leave period for the months in the following format: 3-16, i.e. the student was absent from 3d to 16th day of the month, e.g. 14 days. Some months the student doesn't have any leaves, some months he has.
| Jan | Feb | Mar |...
-------------------------
| 3-16 |empty| 4-8 |...
How to create a formula to calculate the total number of days the student was absent?
Please help. Thank you!
Here's a sample design with a working formula you can test out.
=BYROW(B2:M,LAMBDA(ax,IF(COUNTA(ax)=0,,INDEX(SUM(IFNA(MINUS(--REGEXEXTRACT(TO_TEXT(ax),"\d+$"),--REGEXEXTRACT(TO_TEXT(ax),"^\d+"))+1))))))
-
Related
I'm struggling with a formula where I have to calculate whether a person's absence time is hours or days. The normal formula works but when I change it to ARRAY it doesn't work anymore
data1
Data 2
note
01/01/2021 08:00:00
01/01/2021 09:10:00
only hour
04/01/2021 08:00:00
09/01/2021 08:00:00
days
normal formula:
=IF(IF(AND(DAY(D2)=DAY(E2);MONTH(D2)=MONTH(E2));1;0)=1;(HOUR(E2)-HOUR(D2))/10;DATEDIF(D2;E2;"d"))
array formula
=ArrayFormula(IF(IF(AND(DAY(D2:D)=DAY(E2:E);MONTH(D2:D)=MONTH(E2:E));1;0)=1;(HOUR(E2:E)-HOUR(D2:E))/10;DATEDIF(D2:D;E2:E;"D")))
example link
https://docs.google.com/spreadsheets/d/1EFxugOajxOAEDUgJQEalOXVpKrFwEm2YWSK_N2hq4gw/edit?usp=sharing
I was wondering if Cognos Framework Manager has the built-in function "Last" like in Dynamic Cubes?
Or does someone know how to model following case:
We have two dimensions - a time dimension with year, half-year, quarter and month and another dimension that categorises people depending how long they are attending a project (1-30 days, 31-60 d, 60-180, 180 -365, 1-2 years, +2 years). However the choice of the time dimension level (year, half-year etc.) influences the categorization of the other dimension).
An example:
A person attends a project starting from 15.11.2018 and ends 30.06.2020. The cognos user uses for the time dimension the year level thus 2018, 2019 & 2018 will be displayed.
For 2018 the person will be in the category 31-60 days, since 46 days have passed until 31.12.2018. For 2019 the person will be listed in category 1-2 years as 46 + 365 days will have been passed since 31.12.2019. For 2020 the person will also be in that category as 46 + 365 + 180 day have gone by.
The categories will change if the user selects another time dimension level e.g. half-years:
2nd HY 2018: 31-60 (46 days passed)
1st HY 2019: 180-365 days (46 + 180 --> End of HY2019)
2nd HY 2019: 1-2 years (46 + 180 + 180)
1st HY 2020: 1-2 years (46 + 180 + 180 + 180)
Does someone know how to model dynamic dimension categories based on selection of another dimension (here time dimension)?
The fact table contains monthly data and for the mentioned peroson above there will be 20 seperate records (for each month between november 2018 and june 2020).
For any period, a person may or may not be working on a project.
Without knowing exactly what your data and metadata is it would be somewhat difficult to prescribe an exact solution but the approach would probably be somewhat similar to a degenerate dimension scenario.
You would want to model the project dimension as a fact as well as a dimension. You would have relationships between it and time and whatever other dimensions you need.
Depending on the data and the metadata you might need to do some gymnastics to get there.
If the data was in a form similar to this it would be not too difficult. This is an example to get you an idea about some ways of approaching the problem.
Date_Key Person_Key Project_Key commitment_status, which would be the measure.
20200101 1 1 1
20200101 1 2 0
20200101 1 3 0
20200102 1 1 1
20200102 1 2 0
20200102 1 3 0
20200103 1 1 0
20200103 1 2 1
20200103 1 3 0
In the above, person 1 was working on project 1 for 2 days and then put onto project 2 for a day. By aggregating the commitment status, which is done by setting the aggregate rule property, you would be able to determine the number of days a person has been working on a project no matter what time period you have set in your query.
I am new to DAX and encountered a measure as below,
30 Day Running Total = CALCULATE([Total Sales],
FILTER (ALL (Dates), Dates[Date]>(Dates[Date]) -30 && Dates[Date] <= (Dates[Date] )))
i.e. to calculate Total Sales for last 30 days in a cumulative way for the data from 1st January 2018 to 30 December 2021, the above measure i am not able to understand
My understanding is as below, please let me know where I am moving in wrong direction
FILTER ( ALL(Dates) -> Removes all filters means take date from minimum to maximum from the complete table and i.e. between 1st January 2018 till 30-december-2021
Dates[Date]>MAX(Dates[Date]) -30 -> "Takes Total Sales from the current row in table minus 30 days".
For example if the DAX calculation is on 30th January 2018 then it considers all the total sales from 1st January 2018 till 30th January 2018
Then why do we need to mention another filter Dates[Date] <= MAX(Dates[Date] )?
Thanks in advance for your time
Regards
Sumit Malik
Sumit your main concern seem to be Point (3)
why do we need to mention another filter Dates[Date] <= MAX(Dates[Date] )?
Your doubt is correct, if the data is clean, you do not need to define that upper-bound filter because theoretically considering sales from 30 days ago, there should not be sales after today.
Unfortunately, often data is dirty and there might be Sales in the future. Therefore, defining an upper-bound is a best-practice to avoid this kind of dirty data issues. Remember that in software engineering you program thinking the worst-case scenario, therefore, defining an upper bound does not harm :)
I'm writing a scheduling module and need to show frequency options ranging from once a minute to once a year. Anything over an hour is pretty simple, but I'm looking a formal term for frequencies under an hour.
Every... | Term
Year | Annual
6 Months | Semi Annual
3 Months | Quarterly
1 Month | Monthly
Week | Weekly
Day | Daily
Hour | Hourly
30 Minutes | Semi Hourly (?)
15 Minutes | Quarter Hourly (?)
10 Minutes | Decminutely (?)
5 Minutes | Pentminutely (?)
2 Minutes | Biminutely (?)
Minute | Minutely (?)
If anyone has an idea for a better SE forum that this should be posted on please let me know
How can I, in rainmeter, calculate the number of school days between August 19th 2014 and a certain date? As in, I want to be able to calculate the percentage of how far into the school year today is. So far I have something that calculates the number of DAYS between to dates, but I need to be able to calculate the number of school days too.