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
vbourbeau
Resolver II
Resolver II

Dax left join with dynamic filter on the second table

Hi,

look the image below... and the code here https://we.tl/t-QhP7KEPuaT 

Capture.PNG

So we have 2 tables 'parts' and 'transaction' which are left joined to create the table 'leftjoin'

All work great with the dax command NATURALLEFTOUTERJOIN.

 

But my final goal is to filter the transaction table by date. So if I want only transaction since 2020-04-01 my final table must have only the C part with 2 all the other one must be empty.

 

Thank for your help.

1 ACCEPTED SOLUTION

Hi, @vbourbeau 

 

You may modify the measure as below. The pbix file is attached in the end.

Total Measure = 
var tab = ALLSELECTED('transaction')
var result = 
SUMX(
    SUMMARIZE(
        Part,
        Part[Part],
        "Re",
        COUNTROWS(
            FILTER(
                tab,
                [Part2]=EARLIER(Part[Part])
            )
        )
    ),
    [Re]
)
return
COALESCE(result,0)

 

Result:

d1.png

 

Best Regards

Allan

 

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

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @vbourbeau 

 

I'd like to suggest you modify the filter direction between 'Part' and 'transaction' as 'Both'. The pbix file is attached in the end.

d1.png

 

Then you may create a measure as below.

Total Measure = 
var tab = ALLSELECTED('transaction')
return
SUMX(
    SUMMARIZE(
        Part,
        Part[Part],
        "Re",
        COUNTROWS(
            FILTER(
                tab,
                [Part2]=EARLIER(Part[Part])
            )
        )
    ),
    [Re]
)

 

Result:

d2.png

d3.png

 

Best Regards

Allan

 

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

Thanks

 

But I need to see part without transaction. The goal it's to see the number of transaction for a period of time, even the part without transaction.

the result must be

A empty

B empty

C 2

D empty

...

Hi, @vbourbeau 

 

You may modify the measure as below. The pbix file is attached in the end.

Total Measure = 
var tab = ALLSELECTED('transaction')
var result = 
SUMX(
    SUMMARIZE(
        Part,
        Part[Part],
        "Re",
        COUNTROWS(
            FILTER(
                tab,
                [Part2]=EARLIER(Part[Part])
            )
        )
    ),
    [Re]
)
return
COALESCE(result,0)

 

Result:

d1.png

 

Best Regards

Allan

 

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

gpiero
Skilled Sharer
Skilled Sharer

@vbourbeau 

 

Hi, 
do you mean all visuals should display  only part C with total = 2 if date is >=01/04/2020 && <= TODAY()?

 

Regards

If I can...

 

No the final visual must display each part and the number. That alow us to see empty one.

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.