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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
thyrast
New Member

DAX filter with multiple criteria

Hi, 

I want to filter based on two columns from a table, one containing text(this one I manage), and one filter finding the latest(highest) version(which is a text field, but to find the latest version I assume one must convert or add column to find the max value. 

This is my two tables, they are related by the ID column. I want to filter table 2 based on Type and Version in Table 1. 

Table 1:

IDTypeVersion
5Budget000001
4Prognosis000001
3Budget000002
2Budget000003
1Prognosis000002

 

Table 2:

Budgetdetails_IDMain AccountAmount
5605040000
5606035000
55050-20000
55040-45000
55030200000
3605045000
3606030000
35050-15000
35040-40000
35030200000
2605042000
2606035000
25050-20000
25040-40000
2503025000
4605030000
4606035000
45050-30000
45040-45000
4503010000
1605035000
1606020000
15050-20000
15040-20000
150305000



This is the wanted result, which is a table with the latest version of bugdet and prognosis

Main accountBudgetPrognosis
60504200035000
60603500020000
5050-20000-20000
5040-40000-20000
5030250005000


Thank you for your help. 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @thyrast 

 

Whether the format of Version can be converted to number for easy calculation.

Measure:

Budget = 
VAR _maxversion =
    CALCULATE (
        MAX ( 'Table 1'[Version] ),
        ALLEXCEPT ( 'Table 1', 'Table 1'[Type] )
    )
RETURN
    CALCULATE (
        MAX ( 'Table 2'[Amount] ),
        FILTER ( ALL ( 'Table 1' ), [Type] = "Budget" && [Version] = _maxversion ),
        FILTER(ALL('Table 2'),[Main Account]=SELECTEDVALUE('Table 2'[Main Account])
    )
)
Prognosis = 
CALCULATE (
    MAX ( 'Table 2'[Amount] ),
    FILTER (
        ALL ( 'Table 1' ),
        [Type] = "Prognosis"
            && [Version]
                = CALCULATE (
                    MAX ( 'Table 1'[Version] ),
                    ALLEXCEPT ( 'Table 1', 'Table 1'[Type] )
                )
    ),
    FILTER (
        ALL ( 'Table 2' ),
        [Main Account] = SELECTEDVALUE ( 'Table 2'[Main Account] )
    )
)

Result:

vzhangti_0-1663749863882.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @thyrast 

 

Whether the format of Version can be converted to number for easy calculation.

Measure:

Budget = 
VAR _maxversion =
    CALCULATE (
        MAX ( 'Table 1'[Version] ),
        ALLEXCEPT ( 'Table 1', 'Table 1'[Type] )
    )
RETURN
    CALCULATE (
        MAX ( 'Table 2'[Amount] ),
        FILTER ( ALL ( 'Table 1' ), [Type] = "Budget" && [Version] = _maxversion ),
        FILTER(ALL('Table 2'),[Main Account]=SELECTEDVALUE('Table 2'[Main Account])
    )
)
Prognosis = 
CALCULATE (
    MAX ( 'Table 2'[Amount] ),
    FILTER (
        ALL ( 'Table 1' ),
        [Type] = "Prognosis"
            && [Version]
                = CALCULATE (
                    MAX ( 'Table 1'[Version] ),
                    ALLEXCEPT ( 'Table 1', 'Table 1'[Type] )
                )
    ),
    FILTER (
        ALL ( 'Table 2' ),
        [Main Account] = SELECTEDVALUE ( 'Table 2'[Main Account] )
    )
)

Result:

vzhangti_0-1663749863882.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Greg_Deckler
Community Champion
Community Champion

@thyrast Not clear to me how you arrived at your desired results. But, if you are trying to get the "latest" value somehow then you will need an Index or Date column in your 2nd table.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors