How to connect date table (date type column) to fact table date (datetime type column) type? - powerbi

My date table dimension has date of date type.
Sales fact table has date of type datetime.
In model, how to connect date table (date type column) to fact table date (datetime column) type?

Basically your data model is broken. If you want to join to a Date Dimension then you need to add a column with a Date datatype to your fact table - whether you just add the date column or also drop the timestamp column is up to you and your specific requirements.
If you also need to join to a time dimension then you'll need to add a column to your fact table that has the same datatype as the PK on your Time Dim

Related

Create Rows to the table where the data is missing for specific dates in power BI

I have a table with below columns in my dataset. We have monthly revenue for each resellers in this table.
For few resellers, there will be no data for some particular months, as they didn’t generate revenue on those months. I want to create rows for those resellers with the missing date and the revenue for those missing dates to be updated as blank.
Please advise how we can achieve this.
Current data:
Expected result:
For the missing dates you need to create a date table using the CALENDAR function like this:
Date table = CALENDAR(MIN(Date), MAX(Date))
This will create a table with a single colmn containing all the dates in your table with filled gaps (even if you don't have certain dates in your table). Then you need to create a relationship between your table and the date table.
When you use the date and the revenue in a visual lets say table or matrix all dates will be visible but the revenues will be blank (except for those that actually had a value in revenue).

Power BI Text to Long Date Errors For Data Model

I have Sales table and this table contains OrderDate column this column foreign key. And i have Dates table this table has date column i want to connect for this two table on orderDate and date column. But orderDate columns type is text and i did'nt change the type how can i do this ?
I solved hard way. I am gonna explain;
There is example data : 6 Haziran 2014 Cuma I splitted this data like dd/mm/YYYY
Day=LEFT(Sales[OrderDate],SEARCH(" ",Sales[OrderDate])-1)
Year = RIGHT(LEFT(Sales[OrderDate],SEARCH(" ",Sales[OrderDate],12)),5)
For Month i used conditional column. Like: each if Text.Contains([OrderDate], "Ocak") then 1 else if .....
And finally OrderDateForConnection = Sales[Day] & "/" & Sales[Month] & "/" & Sales[Year] and its worked :)

PowerBI repeat rows from table A for each date in table B

I have two tables one contains User data and other is my dates table.
Is it possible to copy each row from users table for each date from dates table like below?
It is possible using transformations:
Add custom column(column formula is second table name):
Expand column:

how to show data based on date slicer but from 2 dates columns

Currently, I have a report that displays a series of data that I can filter on the basis of a "date slicer (type 'between')". This slicer works with as specifi column "i_date" because a date table (m_date[date]) is used for the slicer and the "i_date" (from another table "interv") is linked together (1:n relathions).
In this other table there is another date type column with the last modification date of the row (interv[modified]).
Now, when a period is selected with the date slicer, I'd like to show the data where interv[i_date] OR interv[modified] are inside the selected period.
How can I do that ?
Using a new column with the newest date between interv[i_date] OR interv[modified] is not a solution, because in this case if a row is modified after the period, it will not be shown. (because interv[i_date] < interv[modified])
solved with a second slicer simply

Power BI: need a formula to create a column from subtracting two distinct dates

I have a date for when someone last bought something (lastbuy) and have an end date (lastday) column and I want to create a new column with this new value which will be a whole number. FYI, lastday and lastbuy are both Date/Time data types. I tried the following:
Column_name = DATEDIFF(lastday, lastbuy, day)
_______________________________________________
Column_name = COUNTX('Table_name', [lastday] - [lastbuy])