PowerBI Desktop: Cumulative of measures from the start of January to Selected Filtered date - powerbi-desktop

I am looking for a way to get a cumulative count using powerBI dax formulas.
I currently have this measure:
[Tasks opened] = distinctcount(id number of tasks that are open)
When I select the filter month (May 2021), it only shows me the opened tasks in May 2021.
Example - Tasks Opened:
>Jan 21 - 5
>Feb 21 - 6
>Mar 21 - 8
>Apr 21 - 2
>May 21 - 7
>Total = 28
When I select the filter for May 21, I want the measure to show that it is 28 instead of 7, and if I select April 21, I want the measure to show 21.
Help is greatly appreciated! Thank you :)
Elaboration:
Basically I want a method where I will be able to filter the tasks opened based on the date selected on the filter.
When the filter month is May, I want to distinct count the number of incidents that has been open for more than 90 days as of 31 May.
It should change accordingly when the filter month is April, so it should distinct count incidents that has been open for more than 90 days as of 30 April.
It should include all the open incidents (whether it is created in Jan/Feb even though the filtered date is April etc).
I figured it should be like if created date is before filter date, resolution date is after filter date and the incident has been open for more than 90 days, that data should be taken into counter.
--> The issue arise where I cant seem to get the right date for the filter date. Currently I used a measure, but the End of Filtered Date seems to only be the last day of the month (i.e. if filtered month is may, the filtered date will be 31 May 2021).
Open incidents = IF(AND(incident_sla[Created]<=[End of Filtered Month],incident_sla[Resolved]>=[End of Filtered Month]),DATEDIFF(incident_sla[Created date],[End of Filtered Month],DAY),0)
The sample excel file can be found here: https://docs.google.com/spreadsheets/d/1wMLrvfAD1gUUIxljjBgcugJsG4o-w4nE/edit#gid=605277454
P.S. Sorry for the bad formatting, I'm not very familiar with using stack overflow.

Related

How to calculate accumulated vacation days in Excel based on days (and hours) worked per month?

TLDR: I need a way to track date values in a dynamic calendar and count the days I've worked on on a monthly base.
So I've made a dynamic calendar (in the 1904 Date system to enable negative time handling) to help me track days and hours worked in Excel that has some automatic features. I would now like to add a calculator to calculate the accumulation of vacation days based on the following conditions:
Days worked per month >= 14
OR
The total hours worked per month >= 35
If one or both of these conditions are met I will receive 2 vacation days (2.5 after the 1st year of employment) and the accumulated vacation days should be shown in a single cell C7 (see picture for reference).
I know that I need to calculate the days that I've worked on on a monthly base and compare the result to the 1st condition (and the same for the worked hours and compare the result to the 2nd condition, but the solution for that is much the same as for the 1st condition). I've made my calendar in a way that I can't use fixed cells to do the calculation, as the length of the calendar is fixed to 53 full weeks and the dates change to accommodate the length according to the year in cell C2 i.e. January 1st will not always be in cell D17. Here are the first 10 rows of my dynamic calendar in Table Markdown format with the formulas as asked.
Year
2023
Quota
=SUM(J11:J375;'2022'!C2)
Hours per week
37.5
Gross working days
=NETWORKDAYS(DATE(C2;1;1);DATE(C2;12;31);'1pyhapaivat'!B7:B21)
Net working days
=COUNTIF(H11:H381;">0")
Vacation Accumulation
Kilometers per day
36
Week No.
Date
Day
Start
end
Hours
Sum
Quota
Kilometers
Holidays
Note
=ISOWEEKNUM(D11)
=SEQUENCE(371;1;DATE($C$2;1;1)-WEEKDAY(DATE($C$2;1;1);2)+1;1)
=D11
=IF(M11="quota";-7,5/24;IF(G11>F11;IF((G11-F11)>(6/24);(G11-F11)-(0,5/24);(G11-F11));""))
=SUMIF(H11:H15;">0")
=I11-COUNTA(G11:G15)(($C$4/5)/24)-COUNTIF(M11:M15;"quota")(($C$4/5)/24)
=COUNTA(F11:F15)$C$8-(SUM(COUNTIF(M11:M15;"Remote");COUNTIF(M11:M15;"Office"))$C$8)
=XLOOKUP(D11;_1pyhapaivat3[Start Date];_1pyhapaivat3[Subject];"")
A snippet of the dynamic calendar
I've tried combining the DATE and SUM functions with other functions like COUNTA, and COUNTIF. I've also tried using different LOOKUP functions but to no avail.
The new dataset filtered by Year
And filtered again by Month

Auto - sorting date in microsoft Excel 2016

I'm trying in excel something very simple but the answer seems more difficult?
At work we created an excel file and from left to right we can fill in details.
For example:
Date EmployeeName Status Comments
But I want that all cases are being automatically sorted by date. And then from the date of today and future ( explain this later at second ).
So for example today is 27 march 2020.
Case1: 1 april 2020 / EmployeeName / Status(open) / commments
Case2: 2 april 2020 / Employeename / Status(closes ) / comments
Now I fill in a new date lets say 29 march 2020. This should automatically pop up above 1 April 2020. However you need to manually click on the sorting table.
Second what if there are cases from before 27 march ( today's date ) can you make them disappear to the bottom of the list? Or in another tab in excel?
I believe that the easiest solution would be to write an if(...) statement to fulfill those terms in moving the selected dates. For sorting the dates I would recommend to have the date format in dd/mm/yyyy. So it would read 27/03/2020, instead of 27 March 2020. I find the default sorting of excel to work better with the number sequence in that format when sorting (ascending and/or descending) dates.

Finding MTD, QTD, and YTD in excel from monthly returns

I've been working on this for awhile and can't seem to find an appropriate way to code this.
Goal: Take a list of monthly returns that currently spans over three years (this is an automated list so it will keep adding months) and find MTD, QTD, & YTD using function so I can automate the process.
Problem: I've tried the OFFSET function, different versions of COUNT, IF statements and can't find a way to properly code the function.
NOTE: this is for stock data/earnings report
Just to clarify, I know how to do this manually, but want to automate the process :) Would be more than happy to use VBA but would like to stick to a simple function if possible...
I'd be more than happy to email the WS to someone. Thanks so much!!
If you want to keep it simple and avoid vba here is a suggestion
The manner in which the data sheet is presented matters.
I assume months go down, with there only being 1 column for 'monthly returns'?
On a separate area/worksheet, set up the months with a value for what they are in the column next to them. Ie
Jan 1
Feb 2
Mar 3
Apr 4
...
Dec 12
then have a drop down where you can select what month it is.
so if it is Jul, you can select Jul.
From here, do a vlookup/indexmatch to pull the number for the month through, so Jul would be 7
From here the MTD is easy.
Do an offset from the beginning of the year to the current month
=offset ([start point],[month number],[columns])
=OFFSET($D$1,$C$21,0)
start point will be one row above Jan, that way when Jan is chosen it will fall onto Jan.
Month number you will get from what was said earlier
and columns will depend on how you place it
YTD, you will do the same as above but have a sum
so
=sum(B3:offset ([start point],[month number],[columns]))
=SUM(D2:OFFSET($D$1,C21,0))
QTD would be easiest just plotting the sums as it would never change
So set out Q1,Q2,Q3 and Q4 as prefixed ones. Then lookup to them.
However, if you want to see the most recent quarter by a formula. On the month number list add a new column which says what quarter it is. Then
Jan 1 1
Feb 2 1
Mar 3 1
Apr 4 2
...
Dec 12 4
It should the read off a formula like so
=SUM(
OFFSET([start point],(INDEX([month number table],MATCH([month],[month list],0),3)-1)*3,0):
OFFSET([start point],INDEX(month number table],MATCH([month],[month list],0),2),0))
=SUM(
OFFSET($D$2,(INDEX($F$2:$H$13,MATCH($C$20,$F$2:$F$13,0),3)-1)*3,0):
OFFSET($D$1,INDEX($F$2:$H$13,MATCH($C$20,$F$2:$F$13,0),2),0)
)
What you are doing is to find the month at the beginning of the quarter and then sum to the current month.
Regarding this bit at the end
OFFSET([start point],(INDEX([month number table],MATCH([month],[month list],0),3)-1)*3,0):
You are finding the month quarter index number(1,2,3,4) and multiplying it by three. The reason you want to take away one before multiplying by three is because you want the start point of the quarter, thus in jan to march, this will be 0, and then you add a row to get the start point being Jan.
In Oct to Dec this will be (4-1) = 3. 3x3 = 9 which will be Oct to make Oct being the start point. Amend as need be.
The yellow section is what your actual information is presented as
The green section is your lookup area
The Blue area is information you are looking for with the lower bit reading from the lookup

Conditional Formulas in Excel 2013

Good day folks! Can you please help me with the following excel problem (Please see below)
July Aug Sep Oct Nov Dec
Total Assets (USD'K) 32 36 38 31
Current Month : (Drop-Down list for all months)
Monthly Change in Total Assets = Current Month - Previous Month
So, here is the situation:
Each month I need to new add statistics to my worksheet. For example, when new data for Total Assets in November arrives, I need to insert it above under the heading "Nov", etc.
After inserting new data, I need to select from the drop-down list current month (for example, "Nov").
Afterwards, "Monthly Change in Total Assets" needs to be calculated automatically. For instance, "Total Assets in November - Total Assets in October".
I assume that, I need to use conditional calculation functions. But it did not work the way I expected.
Can you please help, me. Thank you in advance for your kind assistance.
Sincerely,
Considering the layout of the data is similar to as shown in the image, try this...
In B5
=IF(COUNT(B2:G2)=0,"",IF(COUNT(B2:G2)=1,B2,INDEX(B2:G2,MATCH(B4,B1:G1,0))-INDEX(B2:G2,MATCH(B4,B1:G1,0)-1)))

How to exclude the February 29 - Leap Year in a Date column using Cognos 10 Report Studio?

How do I exclude the February 29 - Leap Year in a Date column in Cognos 10 Report Studio?
This is the column that I'm using for my date prompt
Below is the prompt that I applied on the date column
Depicted below is the details and properties of the date prompt that I will use to filter my report using the date prompt.
So all attributes and measures in the report are filtered using the start date and end date of the expiration date column I used on the report.
How do I avoid the February 29th to add up in my calculated columns (measures)? I want to get all calculation from January 1 to Dec 31 without february 29 that happens every four years? The February 29 data may or may not include a large amount but it has a ripple effect at the year end calculation. That's why I want to exclude Feb 29 included in the computation.
Here's a filter expression that will exclude "leap days":
not (extract(month,[Policy Expiration Date]) = 2 and extract(day,[Policy Expiration Date]) = 29)
Kindly try this.
([Policy Expiration Date] between ?Expiration Start Date? and ?Expiration End Date?)
AND
to_char([Policy Expiration Date],'mmdd') <> '0229'

Resources