Reputation: 1720
I am using SQL server data base. I need to display total no of nights based on checkindate and checkout date. i am new in Power BI.
I tried by quick measure
but it is not working.
Upvotes: 0
Views: 115
Reputation: 13460
You can do this in different ways - calculate the duration in the database, add custom column in M or column in DAX.
In SQL Server use select query like this:
select checkindate, checkoutdate, datediff(day, checkindate, checkoutdate) as duration from table
In M (Power Query) - click Edit queries
to open Power Query editor and then Add Column
-> Custom column
:
Duration.Days(Duration.From([checkoutdate]-[checkindate]))
In DAX - right click your table and select New column
:
Duration_DAX = DATEDIFF('Table'[checkoutdate]; 'Table'[checkindate]; DAY)
Note, that depending on your settings, you may have to use comma (,) instead of semicolon (;) in the DAX expression above.
Upvotes: 1