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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Calculate Difference atone granularity and maintain for further calculations

Hi,

 

I've got a problem that despite excessive googling and even chat GPT I cannot for the life of me solve, I think I'm overcomplicating things. I have produced a dummy dataset which roughly matches the structure I have.

 

Table 1 (Revenues):

MonthClientRev
JanAA200
FebAA200
MarAA200
JanBB300
FebBB300
MarBB300
JanCC400
FebCC400
MarCC400

 

Table 2 is just a client table


AA

BB

CC

 

Table 3 is forecast data:

 

Forecast NameMonthClientValue
XJanAA150
XFebAA300
XMarAA150

 

My desired output is:

 

 RevForecastDifference (at Client level)Pipeline (ER)
Jan9001500900
Feb900300-1001000
Mar9001500900
TOTAL2700600-1002800

 

 

Where difference is 0 if (Revenue - Forecast) for a client is > than 0 (as that means the forecast has been achieved). Pipeline is calculated as revenue - difference (if difference calc'd as a negative value)

 

In my structure Date and Client act as fact tables linked to both datasets. Due to the fact I don't possess a forecast for all clients I need it to calculate the difference at a client level but roll up at monthly level (there are also other filters in my dataset (industry etc)

 

Any help would be greatly appreciated

 

Thanks

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Thanks for this Ashish, I've spent far too much time on this

 

I've tested this and it returns the results I'm looking for as does @MartinMason1989 solution as far as I can see (they both produce the same results) - not sure which one is the better solution currently so I'm going to push them under different scenarios and see which one functions best

MartinMason1989
Regular Visitor

The problem can be solved if you create a star schema with the following structure with Clients and Months as dimension tables.

MartinMason1989_0-1670987938434.png

Definition of Difference (at client level) is following:

SUMX (
    CROSSJOIN ( VALUES ( 'Clients'[Client] ), VALUES ( 'Months'[Month] ) ),
    IF (
        [Forecast] <> BLANK (),
        IF ( [Revenue] > [Forecast], 0, [Revenue] - [Forecast] ),
        BLANK ()
    )
)

And definition of Pipeline (ER) is similar:

SUMX (
    CROSSJOIN ( VALUES ( 'Clients'[Client] ), VALUES ( 'Months'[Month] ) ),
    [Revenue] - [Difference (at client level)]
)

 

Produces the following table:

MartinMason1989_1-1670988184172.png

 

Anonymous
Not applicable

Thanks for this @MartinMason1989 I've spent far too much time solving for this - learnt some useful stuff.


That is the structure of my schema (well the actual one is more compiclated) but I was trying to distill the problem into its basics!

 

This solution works so far in my testing, as in my reply to @Ashish_Mathur they produce the same results, so now I'm going to stress test under different situations to see which one functions best before marking a solution.

 

 

v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Can you please explain how to calculate the Difference (at client level)? At present, I don't understand how to get these results. Perhaps you can use some Mathematics formula to help clarify the logic. 

vjingzhang_0-1670984400404.png

 

Best Regards,
Community Support Team _ Jing

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.