TransWikia.com

Working with two dates fields in table

Data Science Asked by RudyGem on April 3, 2021

I am working with dates.

My fields are in order table:

  • Start date
  • close date
  • order no.

I have to show open orders in each month.

I have created relationship with date table by start date.
I need to relations like:

  • If start date is in this month and before this month and end date is this month means the order is closed in this month itself
    it should count 0
  • If start date is in this month or before this month and close in month after this month
    it should count 1

Now i have created measure like

if(month(startdate)<=month(date),
  if(month(closedate)>month(date),1,0),0)

It assigns 1 for the condition and then I use sum of all ones in visual for every month. Now this works fine with current start date but
for order with startdate before this month its not showing the data
as start date connected to date field in calendar table, when i put this in visual. It not showing the start date for previous months.
For example: If an order having start date in 7th month and end date in 9th month it should be in, 7th month and as well as in 8th month.
Right now its showing only in 7th month just because of relationship, I guess.

Also, its not evaluating the year changes. like its not capable for comparing data for December ’19 and January ’20

One Answer

I used this post to learn how to model something similar in PowerBI/DAX. It summarizes how to use generate to create a calculated table that has one row per date and order that shows the status. When the users creates relationships to other tables (dates and statuses in this example) then it’s relatively straightforward to get information about number of open orders or some other information you included in the calculated table (I used contract price in my set up).

Answered by vizie on April 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP