What is the best way to handle a scenario where multiple date columns exist in a fact table

0 votes

What is the best way to handle a scenario where multiple date columns exist in a fact table?
I have a fact table that contains multiple date columns, such as Order Date, Ship Date, and Delivery Date. I need a Power BI model that allows users to analyze data based on different date contexts dynamically. What is the best approach for handling this in DAX and Power BI? Should I create multiple date tables or use a single date table with role-playing relationships?

11 hours ago in Power BI by Evanjalin
• 22,610 points
17 views

1 answer to this question.

0 votes

Create a disconnected table (Time Periods) with values: "Current Year," "Last Year," etc. Use a DAX measure with SWITCH() and SELECTEDVALUE() to apply filters dynamically:

SalesFiltered =
VAR SelectedPeriod = SELECTEDVALUE('Time Periods'[Period Name])
RETURN
SWITCH(
    SelectedPeriod,
    "Current Year", CALCULATE([Total Sales], YEAR('Sales'[Order Date]) = YEAR(TODAY())),
    "Last Year", CALCULATE([Total Sales], YEAR('Sales'[Order Date]) = YEAR(TODAY()) - 1),
    "Last 3 Years", CALCULATE([Total Sales], 'Sales'[Order Date] >= DATE(YEAR(TODAY()) - 3, 1, 1)),
    [Total Sales]  -- Default case
)

Add the slicer to your report and use SalesFiltered in visuals. The measure will update dynamically! 

answered 11 hours ago by anonymous
• 22,610 points

Related Questions In Power BI

0 votes
1 answer

What is the best way to handle and display hierarchical data in Power BI?

To address filter inconsistencies in your Power ...READ MORE

answered Dec 18, 2024 in Power BI by anonymous
• 3,020 points

edited Mar 6 177 views
0 votes
0 answers
0 votes
1 answer

What’s the best way to handle multi-level filters in a DAX formula to ensure correct data aggregation?

Whenever designing multi-level filters in DAX, there ...READ MORE

answered Nov 7, 2024 in Power BI by pooja
• 21,730 points
112 views
+1 vote
1 answer

What’s the best way to handle multi-level filters in a DAX formula to ensure correct data aggregation?

Navigating through the DAX filter context, particularly ...READ MORE

answered Nov 12, 2024 in Power BI by pooja
• 21,730 points
249 views
0 votes
1 answer

Displaying Table Schema using Power BI with Azure IoT Hub

Answering your first question, Event Hubs are ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,561 views
+1 vote
1 answer

Unable to install connector for Power Bi and PostgreSQL

I think the problem is not at ...READ MORE

answered Aug 22, 2018 in Power BI by nirvana
• 3,130 points
2,891 views
+2 votes
2 answers

Migrate power bi collection to power bi embedded

I agree with Kalgi, this method is ...READ MORE

answered Oct 11, 2018 in Power BI by Hannah
• 18,520 points
1,672 views
+1 vote
1 answer

Connect power bi desktop to dataset and create custom reports

Open power bi report nd sign in ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale

edited Mar 5 1,832 views
0 votes
1 answer

What is the best approach to convert a Date/Time column to a Date data type in Power Query while using DirectQuery from SQL?

For DirectQuery, the best way to convert ...READ MORE

answered Feb 28 in Power BI by anonymous
• 22,610 points
81 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP