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
jjovega
New Member

I need help to summarize the division of 2 columns in different tables with DirectQuery

Hi Guys,

I have to perform a calculation, which I don't know how to solve. The following model is a mini example of my real problem. I have 3 tables with DirectQuery:

 

Table 1

jjovega_0-1622607363383.png

 

Table 2

jjovega_2-1622607414819.png

 

Table 3

jjovega_3-1622607428719.png

 

I need to know the total monthly amount that each of the Offices has, the formula is:

Monthly Amount = SUM (Clients [Payment] / Frequency [Months])

 

The final result should be:

Office 1 = 70
Office 2 = 200

 

Thanks for the help,

1 ACCEPTED SOLUTION

Hi @jjovega 

Due to the filter([Office ID] = Max([Office ID])) in measre, the original measure will show max Office ID's Monthly Amount in Total. I update the measure, please try this measure.

Monthly Amount = 
VAR _Result =
    SUMX (
        SUMMARIZE (
            Office,
            Office[Office ID],
            Office[Office Name],
            "Monthly Amount",
                VAR _T =
                    SUMMARIZE (
                        Clients,
                        Clients[ID],
                        Clients[Office ID],
                        "Divide", DIVIDE ( SUM ( Clients[Payment] ), SUM ( Frequency[Month] ) )
                    )
                RETURN
                    SUMX ( FILTER ( _T, Clients[Office ID] = MAX ( Office[Office ID] ) ), [Divide] )
        ),
        [Monthly Amount]
    )
RETURN
    _Result

Result is as below.

1.png

Best Regards,

Rico Zhou

 

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

4 REPLIES 4
v-rzhou-msft
Community Support
Community Support

Hi @jjovega 

You may relate Table1 and Table2 by [Frequency ID] column and relate Table2 and Table3 by [Office ID] column. I think there may be someting wrong in [Office ID] in Table2. 

From your Statement:

Monthly Amount (Office1) = 120/6 + 600/12 = 70

Monthly Amount (Office2) = 200/1 = 200. 

So Tim should in Office1 and Luis should in Office2.2.png

Measure:

Monthly Amount = 
VAR _T = SUMMARIZE(Clients,Clients[ID],Clients[Office ID],"Divide",DIVIDE(SUM(Clients[Payment]),SUM(Frequency[Month])))
Return
SUMX(FILTER(_T,Clients[Office ID] = MAX(Office[Office ID])),[Divide])

Result:

3.png

Best Regards,

Rico Zhou

 

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

Thanks, @v-rzhou-msft, for the answer, it is exactly what I am looking for. Thanks for the support.


Now I have a question about the total amount of Monthy Amount, since the total sum of the 2 Offices should be 270 and the total in your image is 200.

jjovega_1-1622829422949.png

 

The same thing has happened to me by totaling "Measure", which does not always total the correct amount. Will you know how to solve this problem?

 

This is another example I have:

 

jjovega_0-1622829351182.png

I really appreciate your comments

Hi @jjovega 

Due to the filter([Office ID] = Max([Office ID])) in measre, the original measure will show max Office ID's Monthly Amount in Total. I update the measure, please try this measure.

Monthly Amount = 
VAR _Result =
    SUMX (
        SUMMARIZE (
            Office,
            Office[Office ID],
            Office[Office Name],
            "Monthly Amount",
                VAR _T =
                    SUMMARIZE (
                        Clients,
                        Clients[ID],
                        Clients[Office ID],
                        "Divide", DIVIDE ( SUM ( Clients[Payment] ), SUM ( Frequency[Month] ) )
                    )
                RETURN
                    SUMX ( FILTER ( _T, Clients[Office ID] = MAX ( Office[Office ID] ) ), [Divide] )
        ),
        [Monthly Amount]
    )
RETURN
    _Result

Result is as below.

1.png

Best Regards,

Rico Zhou

 

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

 

Hi @v-rzhou-msft 

I really appreciate your help. That works very fine.

 

Thanks!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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