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

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

Reply
goyalsa
Helper III
Helper III

how to calculate or measure two values from two different table Week-wise

Hi PBI Community,

 

I am stuck on this step and could not figure out how to resolve it. Your suggestion/help will be much appreciated.

 

goyalsa_0-1628738046263.png

The attached screenshot shows two matrices, One shows Demand and the other shows Supply, Now I am stuck on how to calculate/measure demand-supply (Week-wise) and shows in it the table.

 

Many Thanks in Advance !!!

 

1 ACCEPTED SOLUTION

@goyalsa 

 

This may be tricky - how do you define the start of your balance? Basically sounds like a running total calculation?

 

Try a new Measure:

Diff = [_Total Supply Measure] - [_Total Demand Measure]

 

Then do running total of Diff:

 

Balance =

VAR _week = MAX(Date[WeekNum]

RETURN

CALCULATE([Diff], ALL(Date), Date[WeekNum] <= _week )

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

4 REPLIES 4
goyalsa
Helper III
Helper III

Hi @AllisonKennedy ,

 

Thanks for your input. It is working great. 

 

Cheers!!

AllisonKennedy
Super User
Super User

@goyalsa  What does your data model look like? 

 

Assuming you have a DimDate table that is connected to both the Supply and Demand, you should be able to do: 

 

Variance = SUM(Supply[Value]) - SUM(Demand[Value]) 

 

Then put it in a matrix with DimDate[WeekNumber]

https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi @AllisonKennedy 

 

Thanks for the solution, I managed to calculate Supply and demand separately and put them on another matrix. But the stuck part is:

goyalsa_0-1629017268441.png

How to calculate:

 

Total supply at week 202130 - Total demand at week 202130 = Balance

  Then,

For Week 202131,

Balance from week 202130 + Total supply at week 202131 - Total demand at week 202131 = Balance

   Then,

Same for a further week, Like Week 202132

Balance from week 202131 + total supply at week 202132 - Total demand at week 202132 = Balance

 

Your help will be much appreciated !!

@goyalsa 

 

This may be tricky - how do you define the start of your balance? Basically sounds like a running total calculation?

 

Try a new Measure:

Diff = [_Total Supply Measure] - [_Total Demand Measure]

 

Then do running total of Diff:

 

Balance =

VAR _week = MAX(Date[WeekNum]

RETURN

CALCULATE([Diff], ALL(Date), Date[WeekNum] <= _week )

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.