Forum Discussion
Snapshot Comparison based on dynamic date selection
- 2 years ago
just an update how i solved this :
i created 2 tables for dates in SQL DB, uploaded them as independent tables and linked to the main table (which contained the meaures) using SELECTEDVALUE.
thanks all for inputs.
To compare two user-selected dates in Power BI using DAX, you can indeed create a more dynamic solution without the need for two separate tables. Here’s a high-level approach:
Create a Date Parameter Table: This table will allow users to select two different dates for comparison. You can create this table manually or use DAX to generate it.
Create Measures for Each Date Selection: Use DAX to create measures that calculate the values for each of the selected dates. You’ll need to use the CALCULATE function along with the FILTER function to apply the selected dates to your calculations.
Calculate the Differences and Percentage Changes: Create additional measures that calculate the differences and percentage changes between the two selected dates.
Display in a Table Visual: Use a table visual to display your original measures along with the new comparative measures. You can use the date parameter table to control the date selection.
Here’s a simplified example of how you might set up one of these measures:
MeasureForSelectedDate1 =
CALCULATE(
[YourOriginalMeasure],
FILTER(
ALL('DateTable'),
'DateTable'[Date] = SELECTEDVALUE('DateParameterTable'[Date1])
)
)And for the percentage change:
PercentageChange =
DIVIDE(
[MeasureForSelectedDate2] - [MeasureForSelectedDate1],
[MeasureForSelectedDate1]
)This approach allows for a flexible comparison of any two dates selected by the user and can be adapted to include as many measures as needed. Remember to replace [YourOriginalMeasure], 'DateTable', and 'DateParameterTable' with the actual names of your measures and tables. The SELECTEDVALUE function is used to retrieve the user’s selection from the parameter table.
thanks AnalyticsWIzard for a details explanation.
I followed your steps but am getting a boolean output.
MRP_WATERFALL[TOTAL_DEMAND_M] is the expressesion
LAGWEEK is the snapshot table.
TOTAL_DEMAND_SELECTED = CALCULATE(
- sandy_PBI2 years agoFrequent Visitor
just an update how i solved this :
i created 2 tables for dates in SQL DB, uploaded them as independent tables and linked to the main table (which contained the meaures) using SELECTEDVALUE.
thanks all for inputs.