Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
katrine_d2o
Helper I
Helper I

Result difference between dynamic periods

Hello,

 

I have been searching videos and communities without any luck - or perhaps I am just not understanding something.

 

I am comparing a  number of different measures for hotels, like room nights, hours, hours per room night, revenue etc. - that is fine. I want to compare the result with a previous period and show the difference. I want the comparison period to be dynamic - ie. I want to choose to compare with 1 month ago, 3 months ago, 15 months ago etc. I started with creating dateadd for -1, -2, and -3 months, and made a page with each of the results, but I cannot create this for every month back to 2018. 

 

Is there a way to use a slicer to choose the comparison period and calculate the difference? I can always create a list of results for a different period, but I want to see the difference too. I have used multi-row cards here.

 

katrine_d2o_0-1642411171377.png

 

2 ACCEPTED SOLUTIONS
DataInsights
Super User
Super User

@katrine_d2o,

 

You can achieve this with a disconnected table (no relationships). In this example, the table is ComparisonMonth:

 

DataInsights_0-1643640147645.png

 

FactTable (m/d/yy format):

 

DataInsights_1-1643640177042.png

 

Data model:

 

DataInsights_2-1643640195986.png

 

Measures:

 

Revenue Total = SUM ( FactTable[Revenue] )
Revenue Comparison = 
VAR vComparisonMonth =
    SELECTEDVALUE ( ComparisonMonth[Month] )
VAR vResult =
    CALCULATE (
        [Revenue Total],
        DATEADD ( DimDate[Date], vComparisonMonth, MONTH )
    )
RETURN
    vResult
Revenue Variance = [Revenue Total] - [Revenue Comparison]

 

Date slicer uses DimDate[Date]. Comparison Month slicer uses ComparisonMonth[Month].

 

DataInsights_3-1643640307631.png

------------------------------------------------------------

 

DataInsights_4-1643640328025.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

@katrine_d2o,

 

Yes, you need a disconnected date table. You can create one using a calculated table:

 

ComparisonDate = DimDate

 

Change the Revenue Comparison measure to the following. The TREATAS function changes the lineage of the disconnected date table (ComparisonDate) to the main date table (DimDate).

 

Revenue Comparison = 
CALCULATE (
    [Revenue Total],
    TREATAS ( VALUES ( ComparisonDate[Month Year] ), DimDate[Month Year] )
)

 

Slicer interactions should be enabled.

 

DataInsights_0-1644501717579.png

-------------------------------------------------------------

DataInsights_1-1644501738212.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
DataInsights
Super User
Super User

@katrine_d2o,

 

You can achieve this with a disconnected table (no relationships). In this example, the table is ComparisonMonth:

 

DataInsights_0-1643640147645.png

 

FactTable (m/d/yy format):

 

DataInsights_1-1643640177042.png

 

Data model:

 

DataInsights_2-1643640195986.png

 

Measures:

 

Revenue Total = SUM ( FactTable[Revenue] )
Revenue Comparison = 
VAR vComparisonMonth =
    SELECTEDVALUE ( ComparisonMonth[Month] )
VAR vResult =
    CALCULATE (
        [Revenue Total],
        DATEADD ( DimDate[Date], vComparisonMonth, MONTH )
    )
RETURN
    vResult
Revenue Variance = [Revenue Total] - [Revenue Comparison]

 

Date slicer uses DimDate[Date]. Comparison Month slicer uses ComparisonMonth[Month].

 

DataInsights_3-1643640307631.png

------------------------------------------------------------

 

DataInsights_4-1643640328025.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




This is great, thank you. I will test it with the comparison date table I have. Will let you know how it works out.

Hello again @DataInsights ,

I am working with a team in vietnam who has been off for a couple of weeks due to the tet new year, so still waiting for them to update the dataset. Very cumbersome

 

Anyways, the solution above shows me how to use a disconnected table with -x periods. But, what if I have a disconnected date table, how can I choose a previous period?

Situation is the same as above, I want to compare Jan-22 with a random previous period, but not by choosing -x months, but by choosing Mar-19, or Jul-20. What I would like is to have a slicer for the starting month, which is connected as usual. Then I want a slicer for the disconnected table that will display the period I am comparing with and the related results...and of course the differences.

 

Thanks again

katrine_d2o

@katrine_d2o,

 

So in addition to the two slicers (Date and Comparison Month), you want a third slicer with a disconnected date table? This would give you the option of specifying a Date (main date table), and then using either the Comparison Month slicer or disconnected date table slicer to specify the comparison month, right?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @DataInsights 

Thank you for your prompt reply.

I would like only two slicers; the orignal date and comparison date. So, instead of a slicer where I chose -1, -2, -3 etc., I can pick Dec-2021, Jul-2020, Apr-2019. From what I understand, I will need a disconnected date table for this?

@katrine_d2o,

 

Yes, you need a disconnected date table. You can create one using a calculated table:

 

ComparisonDate = DimDate

 

Change the Revenue Comparison measure to the following. The TREATAS function changes the lineage of the disconnected date table (ComparisonDate) to the main date table (DimDate).

 

Revenue Comparison = 
CALCULATE (
    [Revenue Total],
    TREATAS ( VALUES ( ComparisonDate[Month Year] ), DimDate[Month Year] )
)

 

Slicer interactions should be enabled.

 

DataInsights_0-1644501717579.png

-------------------------------------------------------------

DataInsights_1-1644501738212.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.