data protection
22 TopicsAccrued Vacation formula in power BI
Hi, I am working on tracking PTOs in power Bi. I want to create a DAX query on the basis of below parameters 1.) 0 – 2 years = 10 days per year 2 – 10 years = 15 days per year 10+ = 20 days per year 2) If anyone joins on or before 15th of a particular month, then he/she gets leaves for that particular month else from next month onwards. 3) Also, if any employee hits milestone in the current year, e.g. if one of the employee who joined on 9-aug-2022 is completing 2 yr milestone oln 9-aug-2024, ideally his accrual should be =((10/12)*7) + ((15/12)*4)=10.83 . I have tried using below formula but somehow it is not giving me desired output. Let me know if anyone has any inputs or suggestions... Accrued Vacation = VAR StartDate = SELECTEDVALUE('Employee Roster'[Start Date]) VAR CurrentDate = TODAY() VAR CurrentYear = YEAR(CurrentDate) VAR StartYear = YEAR(StartDate) VAR StartMonth = MONTH(StartDate) VAR CurrentMonth = MONTH(CurrentDate) VAR StartDay = DAY(StartDate) VAR Tenure = DATEDIFF(StartDate, CurrentDate, YEAR) VAR AnniversaryDate = DATE(YEAR(StartDate) + Tenure, MONTH(StartDate), DAY(StartDate)) -- Determine Monthly Accrual Rates VAR MonthlyAccrualBefore = SWITCH( TRUE(), Tenure < 2, 10 / 12, Tenure < 10, 15 / 12, 20 / 12 ) VAR MonthlyAccrualAfter = SWITCH( TRUE(), Tenure + 1 < 2, 10 / 12, Tenure + 1 < 10, 15 / 12, 20 / 12 ) -- Determine Effective Date for New Joins VAR EffectiveDate = IF(StartYear = CurrentYear, IF(StartDay <= 15, DATE(CurrentYear, StartMonth, 1), EOMONTH(StartDate, 0) + 1), DATE(CurrentYear, 1, 1) ) -- Calculate Months Before and After Anniversary VAR MonthsBeforeAnniversary = IF( AnniversaryDate <= CurrentDate, DATEDIFF(EffectiveDate, AnniversaryDate, MONTH), DATEDIFF(EffectiveDate, CurrentDate, MONTH) ) VAR MonthsAfterAnniversary = IF( AnniversaryDate <= CurrentDate, DATEDIFF(AnniversaryDate, CurrentDate, MONTH), 0 ) -- Calculate Total Accrued Vacation VAR AccruedVacation = IF( DAY(AnniversaryDate) <= 15, (MonthlyAccrualBefore * MonthsBeforeAnniversary) + (MonthlyAccrualAfter * (MonthsAfterAnniversary + 1)), (MonthlyAccrualBefore * (MonthsBeforeAnniversary + 1)) + (MonthlyAccrualAfter * MonthsAfterAnniversary) ) -- Adjust for the specific case where the anniversary date is after the 15th of the month VAR FinalAccruedVacation = IF( DAY(AnniversaryDate) > 15, (MonthlyAccrualBefore * MonthsBeforeAnniversary) + (MonthlyAccrualAfter * MonthsAfterAnniversary), AccruedVacation ) -- Ensure correct calculation for milestones within the current year VAR CorrectedAccruedVacation = IF( Tenure = 1 || Tenure = 9, (MonthlyAccrualBefore * (MonthsBeforeAnniversary + 1)) + (MonthlyAccrualAfter * MonthsAfterAnniversary), FinalAccruedVacation ) RETURN ROUND(CorrectedAccruedVacation, 2)Solved1.6KViews0likes6Commentsokay icon
I have the following table. And I have the following matrix look The "Planned" measure is: CALCULATE( SUM( fac_NFs_SFs[valor_liquido_nf] ), USERELATIONSHIP( dim_Calendario[Data], fac_NFs_SFs[data_previsao_recebimento] ) ) The "Achieved" measure is: CALCULATE( SUM( fac_NFs_SFs[valor_liquido_nf] ), USERELATIONSHIP( dim_Calendario[Data], fac_NFs_SFs[data_recebimento] ) ) The months "Mar", "Mai" and "Jun" = dim_calendario[mês] I need that when I have a receipt date, all the month contexts have the Okay icon, ignoring the month of the column context. I can't do this because the forecast sum uses the forecast column and the received sum uses the received date column. What do I do?1.1KViews0likes3CommentsHelp with calculating the number of days in between 2 date columns with a specific requirement
Hi, I have the below data set in a Pbix file. Basically what I need it to count the number of days an order was under a specific delivery block (33). On this dataset one order may go under many different blocks, but I only need to see the duration it was under block 33. Looking at the Data below, we can see the order was place on block 33 firstly on 03/14 and taken off 03/15, then placed on 33 again on 03/20 and taken 0ff on 03/22, then once again placed under 33 on 03/28 and taken off 04/01. That would total 7 days under block 33. Note that the old Value Field can be empty or it can have another value, however, we only want to see when the date the New Value changes to 33 and the date it changes from 33 into something else so we can calculate the number of days for that specific action. Any help would be deeply appreciated. Thank you.Solved582Views0likes2CommentsTransform Performance Analyzer query into a new table
Hello! I have a visual table that contains 15 columns coming from 4 different related tables and with different filters applied in my dashboard page. I want to replicate this visual table with exactly the same data shown, but in a PBI table. To do this, I went to the Performance Analyzer tab and copied the query from my visual table. However, when I go to "Create new table" and paste this query, PBI shows me errors in the code. How can I use this query to create a new table in my PBI with the same data as the visual table? This is the query for my visual table: // DAX Query DEFINE VAR __DS0FilterTable = FILTER( KEEPFILTERS(VALUES('BL'[Source])), NOT( 'BL'[Source] IN {"aaa", "bbb", "ccc"} ) ) VAR __DS0FilterTable2 = TREATAS({"BotL"}, 'BL'[Type]) VAR __DS0FilterTable3 = TREATAS({"TAS", "MyProc"}, 'BL'[Local]) VAR __DS0FilterTable4 = TREATAS({2024}, 'Calendar'[Year]) VAR __DS0Core = SUMMARIZECOLUMNS( ROLLUPADDISSUBTOTAL( ROLLUPGROUP( 'Calendar'[MonRef], 'BL'[Evo], 'BL'[Local], 'BL'[Source], 'BL'[PO], 'BL'[Id], 'BL'[X-ID], 'BL'[Name], 'BL'[Status], 'BL'[O Status], 'ACR'[UB] ), "RowTotal" ), __DS0FilterTable, __DS0FilterTable2, __DS0FilterTable3, __DS0FilterTable4, "YTD", 'A_Measures'[YTD], "LD", 'A_Measures'[L D], "YTD_Dynamic_Forecast", 'A_Measures'[YTD_Dynamic_Forecast], "SUMUB", IGNORE(CALCULATE(SUM('ACR'[%_UB]))) ) VAR __DS0PrimaryWindowed = TOPN( 502, __DS0Core, [RowTotal], 0, 'BL'[Name], 1, 'Calendar'[MonRef], 1, 'BL'[Evo], 1, 'BL'[Local], 1, 'BL'[Source], 1, 'BL'[PO], 1, 'BL'[Id], 1, 'BL'[X-ID], 1, 'BL'[O Status], 1, 'BL'[Status], 1, 'ACR'[UB], 1 ) EVALUATE __DS0PrimaryWindowed ORDER BY [RowTotal] DESC, 'BL'[Name], 'Calendar'[MonRef], 'BL'[Evo], 'BL'[Local], 'BL'[Source], 'BL'[PO], 'BL'[Id], 'BL'[X-ID], 'BL'[O Status], 'BL'[Status], 'ACR'[UB]585Views0likes1CommentDisplay a measure in the future
Guys, I need to know if display a measure in the future is viable. Let me explain it. I have this visual above, it shows values by date. I have another measure that sums up the previous month. I want to sum may (maio) and display it as july. Is it possible in Power BI? Because my dataset goes until June (junho)Solved466Views0likes1CommentSelction Period with Last 2 months
Hi Everyone, I stuck in one stage. My scenario is that when I select month, it means displaying the month with the last 2 months in a matrix table like below. When I select Nov-22 in the slicer, the below matrix table displays the month value along with the last 2 months. How can I reach the goal? Thanks in advance..!408Views0likes1CommentReturning a percentage complete
Hello everyone, I have a wierd situation that I'm trying to work through. I'm creating a dashboard that will show the percentage complete for contract deliverable submissions. Source Data: Table 1. JSON file from MS Planner: Tasks are created with the deliverable number (1.2.3.a) as the begining of the task name. Table 2. Standard Excel Workbook: Lists the deliverable number, as well as the amount of deliverable required to fulfill the contract. Example: 1st Column = 1.2.3.a. 1.2.3.b. etc. 2nd Column 52, 260 (whatever is required). My issue: I have a quick measure built to total the amount of times the deliverable number is listed in table 1 which gives me the total amount submitted for each deliverable. What I can't figure out, is how to calculate the percentage complete, i.e., total amount submitted (table 1) against the total amount required (on table 2). Thanks for the help!512Views0likes2CommentsCalcualted column from two distinct tables
Hello , I am creating a calcualted column which is basically dividing one value by another. Both the columns are present in two different tables and they are connected via bridge tabes as nothing is common between them. So below is a picture of my data model. The calculation isnt coming up correctly. What may be the possible reasons for it ? Calcualtion - The One column is from cross channel table and other column is from benchmark table. Both are basically just getting divided.391Views0likes1CommentUsing field parameters in dax measure to calculate topn
I am trying to make this code work but facing some issues. Here Parameter X and Y are field parameters which i am using as a selection criteria. Now, if i remove the variables Value_Parameter & Measure_Parameter and just put the column name in the VALUES and TotalMarks, it works fine. Not sure why i am unable to use field parameters with this code. TopN_Values = VAR Value_Parameter = SelectedValue('Parameter X'[Parameter X Fields]) VAR Measure_Parameter = SelectedValue('Parameter Y'[Parameter Y Fields]) VAR Top3Names = TOPN(3, ADDCOLUMNS( VALUES(Value_Parameter ), "TotalMarks", Measure_Parameter ), [TotalMarks], DESC ) RETURN CONCATENATEX(Top3Names, Value_Parameter , ", ")657Views0likes3CommentsHow to build a line chart without aggregating in Y axis
Hi , I am trying to create a line chart . with date in x axis and values in Y axis . If i pull the values in to Y axis field column i couldnt have the chart without any agg function like (sum,min..) As a work around i changed the date column in to text and tried . Its working now but since i have more than5L rows the chart is with scroll bar down as its very big . how i can fit to page by changing the intervals in X axis Any help from both the methods will be helpful Thanks Ravishankar N R909Views0likes4Comments