PBI Slicer Issue - visualization

I have the following problem applying dax in PowerBI:
DTAT column = Initinal Disposition Date - Document Date
For those cells in the Initial Disposition Date column that I don't have data, the calculation will certainly return negative values since all cells in Document Date column have values.
Is it possible to create a slicer based on the DTAT column where I can omit the negative values on the left hand side (but not delete them since that will change/remove other relevant data in my report)? Like not have it shown in the slicer but it's still there to slide?
I've got something like this to calculate the DTAT in Power BI:
DTAT column = IF( Initinal Disposition Date = blank(), blank(), Initinal Disposition Date - Document Date)
For some reason when I applied the function, there're still negative numbers in the slicer range.
Before-applying the range was: -43,000 to 324
After-applying the range was: -290 to 324
Does anyone have any ideas why the negative numbers still appear? (Even though there are no cells where the Document Date > Initial Disposition Date, except for those that are initially null that will become blank when applying the function).
Thank you so much! I'm new to PBI so any suggestions or ideas are highly appreciated!

I would say that the negative values are right, because you are comparing Document Date behind and ahead the Initial Disposition Date.
If you only want the different between these 2 dates I would say to apply the following formula:
DTAT column = ABS(IF( Initinal Disposition Date = blank(), blank(), Initinal Disposition Date - Document Date))
If are not this the issue you are saying tell me please!

For to the comment for my first answer, you can add a column that return the negative values as 0:
DTAT column(WithoutNegativeValues) = IF(DTAT column<0, 0, DTAT column)
Is this the result you want to obtain?

Related

DAX Calculate Billing Days Between Two Variable Dates

I have a dimdate table that is represented below. I have each day flagged as BusinessDay Y/N. I also have a DimSalesRep table that has a daily goal for each rep. I want to be able to allow users to input a StartDt and EndDt with filters on the report and have a calculated column look at the business days between those dates. I can calculate daysbetween with defined dates but I am unsure how I would use DAX with variable dates that are applied through Report filters.
I should also note I am not sure how best to handle a startdt and enddt filter based of the column, TheDate
Cheers!
Reference your dimdate table twice
StartDate = 'dimdate'
EndDate = 'dimdate'
and use this measure:
Num BusinessDays =
CALCULATE(
COUNTROWS('dimdate'),
'dimdate'[BusinessDay] = "Y",
'dimdate'[Date] >= SELECTEDVALUE(StartDate[Date]),
'dimdate'[Date] <= SELECTEDVALUE(EndDate[Date])
)

Totaling multiple lines into once cell with different date formats

I want to search through a column of dates in the format YYYY-MM-DD (column G - in a random order) and sum up all corresponding cost values for all dates in the same month.
So, for example, the total cost for December 2019 would be 200.
My current formula is:
=SUMPRODUCT((MONTH(G2:G6)=12)*(YEAR(G2:G6)=2019)*(H2:H6))
This gives me the total cost for that month correctly, but I cannot work out how to do this without hardcoding the year and month!
How would I do this with a formula (given the two date columns are a different format)?
You can do this easily combining SUMIFS with EDATE:
SUMIFS function
EDATE function
The formula I've used in cell B2 is:
=SUMIFS($F$2:$F$6;$E$2:$E$6;">="&A2;$E$2:$E$6;"<="&(EDATE(A2;1)-1))
For this formula to work, in column A must be first day of each month!. In cell A2 the value is 01/11/2019, but applied a format of mmmm yyyy to see it like that (and chart will do the same).
paste in D2 cell:
=ARRAYFORMULA(QUERY({EOMONTH(G2:G, -1)+1, H2:H},
"select Col1,sum(Col2)
where Col1 is not null
and not Col1 = date '1900-01-01'
group by Col1
label sum(Col2)''
format Col1 'mmm yyyy'", 0))

Why is my formula returning a number instead of a date?

When trying to add days to a date in another column the value returns as a number, not a date.
I have tried to set the column format as the date for both columns B and C. I also tried using the DATEVALUE() function, but I don't think I used it properly.
=ARRAYFORMULA(IF(ROW(B:B)=1,"Second Notification",IF(LEN(B:B), B:B+1,)))
I want the value in column C to return as a date.
use this with TEXT formula:
={"Second Notification";
ARRAYFORMULA(IF(LEN(B2:B), TEXT(B2:B+1, "MM/dd/yyyy hh:mm:ss"), ))}

Tableau - Divide values from 2 dates

I need help making a division with a relative date range.
For example:
Date Range: 01-01-2015 & 20-01-2015
Divison: 1.209,812 / 1.207,810 = 1,0016575
You can do this with a combination of LOD calcs and a Context Filter.
Select Add to Context on your relative range date filter.
Create Level of Detail calcs to isolate the min and max dates based on your filter
{max([Order Date])}
and
{min([Order Date])}
Create min and max values based on your measures. I'm using the Superstore data set in this example. The calculation states if the date equals the max date, return the Sales value. Repeat for min values.
if [Order Date] = [max date] then [Sales] end
You should have something like this:
Now just create a division between the max and min. You'll need to remove the date from the view for the calculation to render.
sum([max value]) / sum([min value])
See attached sample workbook if needed. https://www.dropbox.com/s/1ed15pwhihmjkdv/181227%20stack%20question.twbx?dl=0

Comparing date value with YEAR in Tableau

I've a calculated field in Tableau which has the Years (Date Value) from a date field. When I compare this calculated field with year of another field, I get error.
IF calculated_Field = YEAR(order_date)
...
1) calculated_Field is the one created using Date value of another field.
2) Order_date is a datetime field.
Error I see in the above IF statement says "Cant compare YEAR and INT values".
When I solved that using below statement, it does not work as expected as IF returns FALSE.
IF INT(calculated_Field) = YEAR(order_date)
Ensure the comparisons are both from YEAR()
IF YEAR(another_field) = YEAR(order_date)
calculated_Field is created using Date value of another_field.
Order_date is a datetime field.