Power Query - Subtract the earliest date in one column from the record-specific date in another column - date

Every month I download a set of data into a report. That data consists of multiple records and each record has a record specific date as well as having the month end report date on the record's data-row.
I have used Power Query to upload all of these month end reports. I want use Power Query to be able to compare the column of record dates with the earliest date in the column of report dates to see if anybody has fiddled any data entry. The query table has the following headings.
Record ID Record Date Report Date
I've tried adding a custom column using the formula = if Record Date < List.Min(Report Date) then "Old" else "New"
this didn't work and I've spent ages trying to get a solution. I've also tried using Groups to get the minimum value, but I lose all of the other columns, which I want to keep. Any help really appreciated.

You have to refer to the fields in [], so here [Report Date]
To pick a column use Source[Field], so here #"PriorStep"[Report Date]
The List.Min function is not pulling as a number so you cant use <
Insert a Number.From in front of the calculation to convert to number
Same need to add Number.From in front of [Record Date] pulling as a date
Combined code:
#"Added Custom" = Table.AddColumn(#"PriorStep", "Custom", each if Number.From([Record Date])<Number.From(List.Min(#"PriorStep"[Report Date])) then "Old" else "New")

Related

Sisense, display number of days in date filter

Have a date filter on the dashboard that allows for a custom date range:
Dashboard Date Filter
How can I add a the number of days in the filter to a formula? Just trying to show the number of days in column of a pivot table. In this example the date range is 45 days. The dataset doesn't have one record for each day, so a distinct count of days from the data set returns 42.
Is it possible to use the date from and date to filter values in formula? DDIFF([datefilter-from], [datefilter-to])
Extract the date from the fact table and create a dimension table which will contain all the dates.
Link the date column from fact table and dimension table. Use the dimension table's date column in filters.

Max Date in Qlikview Expression

I have a Qlikview where I have data loaded for various dates. The pivot table in the qlikview shows the change in values from previous day. so for every selected day, I need the previous date to pick values from.
So I have
Dates 31/08/2021, 28/07/2021, 27/07/2021, 25/07/2021
Based on the date selected, i want the previous date. how do i do it in the qlikview expression.
Assuming your field is named DateField you could try this:
=Max({1<DateField = {"<$(=Min(DateField))"}>} DateField)
"<$(=Min(DateField))" will search for all dates less than the [minimum] date selected. The Max expression will then return the greatest date of this set.

DAX and FORMAT function

i have a field for date with date, month and year.In my visualization, I need date to be displayed in (MON-Year) format.
I switched to data view, created calculated column with
Mon-Year = FORMAT('table'[Date],"YYYY-MM")
Now it's getting displayed as (YEAR and Month number) but I want to change it as month name.
After changes in data view, when I close apply, the column is present but there is no data type visible.
Should I create different calculated fields for year and month separately and then concatenate it?
any help would be appreciated.
If you want month first, then maybe you should specify it that way.
Mon-Year = FORMAT('table'[Date],"MMM-YYYY")
This may be useful for you:
https://learn.microsoft.com/en-us/dax/custom-date-and-time-formats-for-the-format-function

How to return the last day of each month

I am creating a view where i have multiple records showing up for each month.
Example: January is showing 20 records and February is showing 30 records. I only want the last record of EACH MONTH to show up. So i want to see 1 record for each month.
I have already tried the first() and last() table calculation, but it does not filter by month, but by column.
If you just apply first and last on the dataaset then you won't get the correct output, If you need for every month then you need to divide the partition to year and month and then apply the max on the specific partition.
Try this way:
Place the order date in Exact date format and change the property to discrete
Now extract the year and month in separate calculated fields and place in detail.
Year:
year(Date)
Month:
Month(date)
Now create one more calculated field and write below code:
WINDOW_MAX(MAX([Order Date]),FIRST(),LAST())
Try This
1 Calculated Field - DateMonth
Datetrunc('month',Date)
2 Calculative field - LastDate
{ FIXED DateMonth: max(Date)}
3 Calculative Field- Filter
if lastDate=Date then 'Yes' else 'No' end

How to find records by month Datamapper

In my project I need to have ability ti add reports.
Adding a report user can choose date for placing his report. (not created_at)
I save this data in "Date":DataTime - format column(2012-03-24T00:00:00+00:00)
User selects date from datepicker and than i parse it with DateTime.parse(2012-03-24) and than save to DB.
Than user via datepicker selects a month.
How can I correctly perform a query to find all records for perticular month?
Is there any method to find by month?
No. You should calculate margin dates and use :date => range (it will create sql BETWEEN query). For example:
month = params[:month].to_i
date_a = DateTime.new Date.today.year, month, 1
date_b = (date_a >> 1) + 1 # will add a month and a day
Page.all :updated_at => date_a..date_b