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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
HimanshuSingh
Regular Visitor

Creating a data model which changes the join condition between two tables based on filters

Hello All

Problem: The user can select two period, say 202307 (comparative period) and 202310 (current period), I need to compute for that between the two periods:

List Price Band growth: [ List Price of Current Quantity (LP: 150, Current Quantity 7, Period 202310) minus Comparative Period List Price Current Quantity (LP: 140, Current Quantity 7, Period: 202307 ] X Current Period Quantity (Period 202310, Quantity: 7)  The KPI needs to be calculated for each customer and then aggregated.
Data Structure:
I have a table with active subscriptions and List Prices. Data structure of Active_Subscriptions is such that it will contain a row for each period if it is active (and even if no changes have been made to the subscriptions (period between 202307 to 202309)):

YYYYMMCustomerProductQuantityNet Price
202307AB5100
202308AB5100
202309AB5100
202310AB7120

The list price table is also similar which contains the list price for each month and quantity:

YYYYMMProductQuantityList Price
202307B5120
202307B7140
202308B5120
202308B7140
202309B5130
202309B7150
202310B5130
202310B7150

 

Solutions explored so far: The easiest solution which I have in my mind is to use a direct query mode and create parameters which will change the Current Period and Comparative Period values and pass it in the SQL query from where I am pulling the tables. The problem is that it will be very time consuming. The data has around 10 million records.

Does the community think there is another way to do it?

Thanks

1 ACCEPTED SOLUTION

HI @HimanshuSingh ,

 

For this you need to create a disconnected table for the filtering of the date period you want to compare and then making a measure that allows to get that specific value for the specific time.

 

Something similar to:

Previous Period = CALCULATE (SUM(Table[Column]), Table[Date] = SELECTEDVALUE(DisconnetedTable[Date]))

Depending on the calculations you need you can then use this measure to make differences and variations and cumulatives.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @HimanshuSingh ,

 

Create a dimension table for periods and related both tables based on that table with one to many relationship this will allow for the filtering and comparision.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



The problem is not filtering the correct months. I want the user to select the current months and comparative months and the computation changes as per the selection

HimanshuSingh_0-1723549660807.png

 




If I were to make my KPI in excel it would merge the two rows in the subscription table and lookup the list prices from the selected months like this:

ABCDEFGHIJKL
Reporting MonthCustomerProductCurrent PeriodComparative PeriodCurrent QuantityComparative QuantityCurrent List Price Current Quantity (Based on Current Quantity=7 and Period=202310)Compartive List Price Current Quantity (Based on Current Quantity=7 and Period=202310)Current List Price Based on Comparative Quantity (Comparative Quantity=5 and Period = 202307)Comparative List Price Based on Comparative Quantity (Comparative Quantity=5 and Period = 202307)List Price Band Changes (H-I) x F
202310AB2023102023077515014013012070


Do you think this will be possible in Power BI?

HI @HimanshuSingh ,

 

For this you need to create a disconnected table for the filtering of the date period you want to compare and then making a measure that allows to get that specific value for the specific time.

 

Something similar to:

Previous Period = CALCULATE (SUM(Table[Column]), Table[Date] = SELECTEDVALUE(DisconnetedTable[Date]))

Depending on the calculations you need you can then use this measure to make differences and variations and cumulatives.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors