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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
croberts21
Responsive Resident
Responsive Resident

Getting sum of costs from one table, sales from another.

I have Free PBI Desktop v2.105 (64 bit free version May 2022) on 64-bit Windows Server 2019 Datacenter v1809.

 

I think I have a case of disconnected tables. Here are the basic table layouts with relevant fields: 

Table: Test2022

Fields: Cost date, Total Cost

Table: Invoice

Fields: invoicedate, invoiceamt

 

The tables are not linked with any other field. But the dates are common between the 2 tables. 

For each month I want to show a row in a table. In each row will be the month name, the costs for that month from Test2022[Total Cost], and the sales for that month from Invoice[invoiceamt]. Both tables have a date in them. I've never done this before and have watched a short video on this but didn't understand it. 

The output table would look like this: 

 

Month    Costs     Sales    Pct of Sales

Jun 2021  100   1000   10.0%

Jul 2021   150   35  23.3%

Aug 2021  85   305   27.9%

 

The "Pct of sales" would be calculated as DIVIDE(Costs, Sales). 

Any idea what functions I should look at? This is a totally new calculation for me. 

Thank you!

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @croberts21 ,

According to your description "The tables are not linked with any other field. But the dates are common between the 2 tables. ", not sure if the two tables are related with each other.

A. If the two tables don't have relationship between each other, here's my solution.

Create two measures.

 

Sales =
MAXX (
    FILTER (
        ALL ( 'Invoice' ),
        EOMONTH ( 'Invoice'[Invoicedate], 0 )
            = EOMONTH ( MAX ( 'Test2022'[Cost date] ), 0 )
            && YEAR ( 'Invoice'[Invoicedate] ) = YEAR ( MAX ( 'Test2022'[Cost date] ) )
    ),
    'Invoice'[Invoiceamt]
)
Pct of Sales = DIVIDE(MAX('Test2022'[Total Cost]),[Sales])

 

Put the Test2022 table and the two measures in the visual, get the result.

vkalyjmsft_0-1656646127191.png

B. If the two tables have relationship with the date column, here's my solution.

Create a measure.

 

Pct of  Sales2 =
DIVIDE ( MAX ( 'Test2022'[Total Cost] ), MAX ( 'Invoice'[Invoiceamt] ) )

 

Put the Test2022 table, the Invoiceamt column and the measure in the visual, get the result.

vkalyjmsft_1-1656646576080.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

View solution in original post

1 REPLY 1
v-yanjiang-msft
Community Support
Community Support

Hi @croberts21 ,

According to your description "The tables are not linked with any other field. But the dates are common between the 2 tables. ", not sure if the two tables are related with each other.

A. If the two tables don't have relationship between each other, here's my solution.

Create two measures.

 

Sales =
MAXX (
    FILTER (
        ALL ( 'Invoice' ),
        EOMONTH ( 'Invoice'[Invoicedate], 0 )
            = EOMONTH ( MAX ( 'Test2022'[Cost date] ), 0 )
            && YEAR ( 'Invoice'[Invoicedate] ) = YEAR ( MAX ( 'Test2022'[Cost date] ) )
    ),
    'Invoice'[Invoiceamt]
)
Pct of Sales = DIVIDE(MAX('Test2022'[Total Cost]),[Sales])

 

Put the Test2022 table and the two measures in the visual, get the result.

vkalyjmsft_0-1656646127191.png

B. If the two tables have relationship with the date column, here's my solution.

Create a measure.

 

Pct of  Sales2 =
DIVIDE ( MAX ( 'Test2022'[Total Cost] ), MAX ( 'Invoice'[Invoiceamt] ) )

 

Put the Test2022 table, the Invoiceamt column and the measure in the visual, get the result.

vkalyjmsft_1-1656646576080.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.