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! Learn more

Reply
EduardD
Helper IV
Helper IV

how to achieve this result: Return if (<condition>, Table1, Table2)?

Hi team, 
I need to write a DAX query I will call externally from paginated report that based on the parameter should return calcaulted in DAX Table 1 or Table 2.
VAR Table1= ..

VAR Table 2=...
EVALUATE 
if (<condition>, Table1, Table2)

doesn't work for Table as an argument. I wonder if there are other options I can leverage.
Thank you in advance.

2 REPLIES 2
Anonymous
Not applicable

Hi @EduardD ,

First of all, in DAX Query, IF statement and Swith statement are not able to return the table directly, they return a scalar value.

Then I create a table as you mentioned.

vyilongmsft_0-1723599464094.png

I think you can use this DAX code to extract different tables directly.

EVALUATE
VAR _Sales2023 = 
    SELECTCOLUMNS(
        FILTER(
            Sales,
            Sales[Year] = 2023
        ),
        "Date", Sales[Date],
        "Amount", Sales[Amount]
    )

VAR _Sales2024 = 
    SELECTCOLUMNS(
        FILTER(
            Sales,
            Sales[Year] = 2024
        ),
        "Date", Sales[Date],
        "Amount", Sales[Amount]
    )

    RETURN
    _Sales2023

vyilongmsft_1-1723599597157.png

vyilongmsft_2-1723599617635.png

 

 

 

Best Regards

Yilong Zhou

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

Hi @Anonymous . Thank you for suggestion. If I got it right you recommend to union table1 and 2 into one table and have extra column that differentiate between parameters. Then use filter to return table 1 or 2 rows based on parameter selection. It might work, the only problem I envision is that this table would have a key column no longer unique, that will break 1 to many relationships with other tables.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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