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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Andreasweiz
Frequent Visitor

Calculation between totals in different tables

Hello,

 

I am trying to calculate a percentage between two values whichs are in two different matrixes. See screenshot.

 

For example, I'd like to divide the total for week 31 from the top matrix (lets call the table behind it Table1) by the total for week 31 from the bottom matrix (Table2). To be able to calculate a percentage.

 

Seems relatively straight forward but I am not able to do it.

 

You're help would be appreciated.

 

Thanks,
Andreas

tempsnip.png

3 REPLIES 3
amitchandak
Super User
Super User

@Andreasweiz , If they are two different data tables in power bi(Not only visual) , Then you need a common date/week table and then you can take diff when data is displayed by week

 

or you can create a week wise measure

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

measures , create like this for both tables 
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))

Hi,

 

Thanks for your answer.

 

I am trying to go down the first route you mentioned as the second I get this:

Andreasweiz_0-1634831921561.png

And I'd like to continue in DirectQuery mode.

 

I have created a table called YearWeek containing distinct year/week values and have created a relationship between it and the two tables which are involved.

 

I now need some sort of DAX calculation to get this division between two values from two different tables.

 

Thanks,

Andreas

Hi @Andreasweiz ,

Could you please provide the setting of the top and bottom matrix in the Fields panel and some sample data from the involved tables? Since the table fields referenced by these two matrixs are from different tables and is there any relationship created between them? Do you want to get the percentage of data for the same week for the top and bottom matrix?

yingyinr_0-1635241513940.png

For the percentage calculation, you can refer to the following links to get it by using DIVIDE function.

Calculating Percentages

Calculating Percentage (%) Margins In Power BI Using DAX

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.