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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PaulDBrown
Community Champion
Community Champion

Totals combining sums from two different fact tables: 'Estimates' and 'Sales'?

Hello everyone,

 

I kndly request help to solve what must be a very common scenario: combining and computing data from different tables to compute totals. In this case, the model is basically a sales estimates table, a sales table and two lookup tables (YearMonth - due to different granularity), and an ITEM table. 

 

Two.JPG

 

 

 

 

The 'rogue' measure in the picture  is "Measure: Estimates, or if not sales". This measure basically computes the value for an 'estimate', but if the 'estimate' is empty/0, then it returns the value in 'sales'.

 

And of course the subtotals and total don't add up; the value computed is the value from the Estimates measure.

 

So how can I obtain the correct subtotals and total for this measure?

 

Thank you for your help (it's driving me mad...)

Regards,

 

Paul.

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






2 ACCEPTED SOLUTIONS

@v-shex-msft

 

I've worked it out!!!

 

It's taken me a while (days in fact...) but I've finally found out how to get the right values/totals in the right places. I'ts basically nested SUMX. 

 

For those who might come across the same problem, the steps I've taken are as follows:

 

1) to obtain the initial results (see the problem in the first thread, the measure computing the 'Result' column is a simple IF function

2) to obtain the correct totals by month, I used SUMX in the expression SUMX ITEM = SUMX('ITEM'; [result])

3) finally to obtain the correct 'total', with everything else in place, I nested the previous expression in a new SUMX, this time by month: SUMX('MONTH'; [SUMX ITEM])

 

et voilà!

SUMX MONTH SUMX ITEM.JPG

 

 

 

 

The amount of time I would have saved if I had come across this solution ages ago...





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

As a follow-up, I just read in Matt Allington's website (exceleratorbi.com) that nested SUMX is inefficient, and followed an example he posted talking about nested SUMX and the better option of: SUMMARIZE

 

SUMMARIZE.JPG

 

Thank you @MattAllington for your very helpful blog and examples!





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

5 REPLIES 5
PaulDBrown
Community Champion
Community Champion

Please, anyone?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi @PaulDBrown,

 

I think you can create a new table with summary 2018 estimates records and sales records, then use new table to create matrix visual.

Table = 
ADDCOLUMNS (
    '2018 Sales',
    "Sales",
    VAR temp =
        SUMX (
            FILTER (
                ALL ( Sales ),
                [Item] = EARLIER ( '2018 Sales'[Item] )
                    && [Month] = EARLIER ( '2018 Sales'[Month] )
            ),
            [Sales]
        )
    RETURN
        IF ( temp <> BLANK (), temp, [Estimates] )
)

9.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@v-shex-msft

 

Thank you Xiaoxin for the suggestion! I actually have been trying to avoid creating new tables since, from what I've read, it's not the most efficient solution (performance-wise). I will definitely keep your suggestion in my "toolset" if I'm unable to find a 'measure'-way round this.

 

I have been playing around with SUMX (SUMX ITEM = SUMX('ITEM';[Result])) and have achieved a limited degree of success: the measure delivers at the "month" level, but the total is till not correct (quite baffling to me). (see below)

 

SUMX example for two fact tables.JPG

 

Any possible solutions to obtain the grand total?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@v-shex-msft

 

I've worked it out!!!

 

It's taken me a while (days in fact...) but I've finally found out how to get the right values/totals in the right places. I'ts basically nested SUMX. 

 

For those who might come across the same problem, the steps I've taken are as follows:

 

1) to obtain the initial results (see the problem in the first thread, the measure computing the 'Result' column is a simple IF function

2) to obtain the correct totals by month, I used SUMX in the expression SUMX ITEM = SUMX('ITEM'; [result])

3) finally to obtain the correct 'total', with everything else in place, I nested the previous expression in a new SUMX, this time by month: SUMX('MONTH'; [SUMX ITEM])

 

et voilà!

SUMX MONTH SUMX ITEM.JPG

 

 

 

 

The amount of time I would have saved if I had come across this solution ages ago...





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






As a follow-up, I just read in Matt Allington's website (exceleratorbi.com) that nested SUMX is inefficient, and followed an example he posted talking about nested SUMX and the better option of: SUMMARIZE

 

SUMMARIZE.JPG

 

Thank you @MattAllington for your very helpful blog and examples!





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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