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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
sanc_152
Helper I
Helper I

Creating cross join functionality

Hi  ,  @Ahmedx , @Greg_Deckler , @amitchandak Please can you help on this scenario.

I am dealing with problem beacuse of auto exist functionality in PBI
I have 3 tables. Product and customer are 2 dimension tables.
And 1 fact Table .
When I M putting column from 3 tables in Matrix chart it is generating cross join result whenever I am trying to put if condition.

I want to calculate win mesure which dynmically generate win or loss result from columns 1stforecast and 2ndforecast.
1.whichever is closest to sales is winner 
2.if sales is null or 0 then result will be "NA"
3. if sales is 0 or null but one of the vlaues is present from 1stforecast and 2ndforecast then winner will be the column who having values.



Fact table:

Csutomer Product Sales1stforecast2ndtforecast
ABC110

 

20

22
BAC2112115
ABC3122213
ABC4132320
DA5024 
DA6 2526

Customer table

CustomercodeDescription
ABCSoap
BACnutrition
ABCSoap
ABCSoap
DATyre
DATyre

Prdouct table:

Product KeyProduct description
1A
2b
3c
4d
5e
2 REPLIES 2
Anonymous
Not applicable

Hi @sanc_152 ,

 

My measure:

Winner = 
VAR _SALES =
    SUM ( 'Fact table'[Sales] ) + 0
VAR _FORECAST1 =
    SUM ( 'Fact table'[1stforecast] )
VAR _FORECAST2 =
    SUM ( 'Fact table'[2ndtforecast] )
VAR _DIFF1 =
    ABS ( _SALES - _FORECAST1 )
VAR _DIFF2 =
    ABS ( _SALES - _FORECAST2 )
RETURN
    IF (
        HASONEVALUE ( 'Fact table'[Csutomer] ),
        IF (
            _SALES = 0,
            IF (
                ISBLANK ( _FORECAST1 ),
                IF ( ISBLANK ( _FORECAST2 ), "NA", "2ndforecast" ),
                IF ( ISBLANK ( _FORECAST2 ), "1stforecast", "NA" )
            ),
            IF (
                _DIFF1 = _DIFF2,
                "NA",
                IF ( _DIFF1 < _DIFF2, "1stforecast", "2ndforecast" )
            )
        )
    )

Matrix:

vrzhoumsft_1-1682933069509.png

Result is as below.

vrzhoumsft_0-1682933041331.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.

@Anonymous 
Thanks ,Great it is me giving me the result I want .But need one more if condition :

when actuals is 10 ,1stforecast=0 and 2ndforecast=30 then 2ndforecast should be winner .
Can we add this condition ?


Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.