How to display current date and time in power bi visuals? - powerbi

Is it possible to add a card in power BI that shows the current date and tome time??
Many thanks!

You can show only time of last data refresh. Use one of this:
DAX Measure
MyNow = TODAY()
returns single date
PowerQuery
MyNow = DateTime.LocalNow()
returns table with single row & col

Current Date & Time:
MyCurrentDateAndTime := NOW()
The value will be updated each time you open the worksheet.

Related

Date differences in Power BI- Power Query

Hello Everyone i am trying to get a Days Interval column through getting the differnce between Todays Date and a column Refresh date in Power Query, How do i go about it.
I want to do this in Power Query
= DateTime.Date(DateTime.LocalNow())-[Refresh Date]

Slicer Only Show Month / Year and Filter On That

I have a table with a value ReportDate, which is in the format '03/01/2020'. I want to create a slicer in my Power BI report that displays only the format '03/2020' and the user can then select the value of the month and year to display, and it will display the data for that month (regardless of the day value). How would one go about doing this? I know technically I can add a new column in the database table, but unfortunately I do not have access to changes in the database and as such, would like a Power BI solution.
In the Power Query Editor create a new column with formula
Date.ToText([Date], "MM") & "/" & Date.ToText([Date], "yyyy")
Change [Date] to whatever your date column is called. Date.ToText converts a date time to text, which is then concatenated. You can then filter on that column. For issues like this it is best to have some sort of calendar table.
You can create a new column in using query editor in power bi:
mon_year = left(<column_name>, 3) & Right(<column_name>, 4)
Note: Make sure your are connected to dataset in import mode because in live connection you will not be able to create New Column in Power BI.

Calendar/GenerateSeries DAX functions giving error "The start date or end date in Calendar function can not be Blank value."

I am trying to create a separate table that will have dates between Start_Date and End_date. These dates are measures. Below is the detail of my requirement..
I have a Dropdown in report which lists distinct dates of fact.sales table and is a single select. I am saving this selected date in a Measure --> End_Date = selectedvalue(sale[Delivery Date Key]).
Now I am showing a report using what-if parameter. The slider slides from values 1 to 24.
Now I am creating another Measure..
Start_Date = date(year('Date'[End Date]),MONTH('Date'[End Date])-Cust_Key[Cust_Key Value],1)`
The Problem - When I try to use calendar function to create table using below DAX function, I get an error - "The start date or end date in Calendar function can not be Blank value."
calendar = calendar('Date'[Start Date],'Date'[End Date])
Can measures not be used inside the Calendar/GenerateSeries function.. Thanks in advance..
The SELECTEDVALUE function will return a blank if you haven't selected a single value. Note that calculated tables cannot read slicer values since they are only computed when the data is loaded, not whenever you interact with a slicer. Therefore, your End_Date measure returns a blank since it isn't filtered by the slicer.
You can use measures within any calculated tables but they won't interact with any dynamic slicers or filters. Calculated tables in your data model are static once the model is loaded. You can, however, use temporary/dynamic calculated tables within a measure so long as the measure still returns a single value at the end.

power bi date measure card

I have a dashboard that needs to display the beginning of the week, on Monday, of the week that I'm in. So for example, if its 1/7/2020, this card would show 1/6/2020. Here is the code I was trying:
Report Date = CALCULATE(TODAY(), FILTER('Calendar', 'Calendar'[WeekStartDate]))
The column in the Calendar table is Weekstartdate, which is accurate and does show the week of 1/6/2020 with the corresponding dates to it; however, it looks like it won't filter it from today's date.
Any ideas? or advice on what I'm doing wrong?
If what you are looking for is a single date, which gives the week start date based on Today's date, you should create a measure:
WeekStartMeasure = TODAY()-WEEKDAY(Today(),2)+1
If you are creating week start date based on a column, then you should create a column with the following calculation:
WeekStartDate = Table[Date]- WEEKDAY(Table[Date],2)+1
Once you create the measure/column, you can use it in the visualization to get the desired result.
We can calculate this way also
if (
WEEKDAY(TODAY(),1) == 1,
TODAY(),
TODAY() - (WEEKDAY(TODAY(),1) - 1)
)

Subtracting measure value from each row of a table in Microsoft Power BI

I have created two slicers in Power BI for Month and Year. These take the month and year value and in return generate a date.
Eg. Month - May & Year- 2019 generates 01/05/2019 with the help of the a measure formula :
MyFilterDate = DATE(SELECTEDVALUE(ListoY[Year]),SELECTEDVALUE(ListoM[Month],0),"01")
I want to subtract this date with one that is already in a column in the table.
I'm facing an issue when I try to subtract the measure from the existing column by writing DAX.
SUBVALNEW = DATEDIFF([MyFilterDate],Table[Date],DAY)
But when I try to do so, the result is not right. In fact when I try to check the value of [MyFilterDate] in the Data Model, it is not the same value as one calculated in the measure. (It instead looks like it displays the date in Table[Date])
Is there any way to subtract a Dynamically chosen date from a date in a column?
Any help would be appreciated.
I understand what your thinking patern is but power bi works a bit different. Dynamic measures cannot be used with calculated columns. When doing so the value of the measure is not set.
The way to go about this is by creating a Date table:
Date = CALENDAR(MIN(CalendarWeek[Date]);MAX(CalendarWeek[Date]))
Do NOT connect it to the model. From here you can make 2 slicers (based on the Date table). One your set to the month and the other to the year.
Next step is to adjust the MyFilterDate
MyFilterDate = DATE(SELECTEDVALUE('Date'[Date].[Year]);SELECTEDVALUE('Date'[Date].[MonthNo]);"01")
Make SUBVALNEW a measure (cannot be a column because it is dynamic!)
SUBVALNEW = DATEDIFF([MyFilterDate];SELECTEDVALUE(CalendarWeek[Date]) ;DAY)
Ass the Measuer to your visual, see end result below)