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
Setosa
Frequent Visitor

How to Filter in Summarize in Dax

I have a dax code as follows and I need to add a filter argument but somehow the result is coming unexpected. 

 

 

 

 

VAR CurrencyAmounts =
 SUMMARIZE(
    FILTER(facttable, facttable[COL] = "abc"),
                facttable[Currency], 'facttable'[Amount])

 

 

 

 

 

 

 

Rate_1_Equivalent = 
VAR CurrencyAmounts = SUMMARIZE('Facttable', facttable[Curreny], 'Facttable'[Amount])
VAR USD_Rate_1 = MAXX(FILTER('slicertable', slicertable[Curreny] = "usd"), 'slicertable'[rate_1])
VAR EUR_Rate_1 = MAXX(FILTER('slicertable', slicertable[Curreny] = "eur"), 'slicertable'[rate_1])
VAR CNY_Rate_1 = MAXX(FILTER('slicertable', slicertable[Curreny] = "cny"), 'slicertable'[rate_1])

RETURN
SUMX(
    CurrencyAmounts,
    SWITCH(
        facttable[Curreny],
        "usd", 'Facttable'[Amount] * USD_Rate_1,
        "eur", 'Facttable'[Amount] * EUR_Rate_1,
        "cny", 'Facttable'[Amount] * CNY_Rate_1
    )
)

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-jiewu-msft
Community Support
Community Support

Hi @Setosa ,

Please try the following methods and check if they can solve your problem:

1.Create the simple table.

vjiewumsft_0-1708911576512.png

vjiewumsft_1-1708911598676.png

2.Create the new measure to filter.

 

Rate_1_Equivalent = 
VAR CurrencyAmounts =
    SUMMARIZE(
        FILTER(facttable, facttable[COL] = "abc"),
        facttable[Currency],
        "TotalAmount", SUM(facttable[Amount])
    )

VAR USD_Rate_1 = MAXX(FILTER(slicerTable, slicerTable[Currency] = "usd"), slicerTable[rate_1])
VAR EUR_Rate_1 = MAXX(FILTER(slicerTable, slicerTable[Currency] = "eur"), slicerTable[rate_1])
VAR CNY_Rate_1 = MAXX(FILTER(slicerTable, slicerTable[Currency] = "cny"), slicerTable[rate_1])

RETURN
SUMX(
    CurrencyAmounts,
    SWITCH(
        [Currency],
        "usd", [TotalAmount] * USD_Rate_1,
        "eur", [TotalAmount] * EUR_Rate_1,
        "cny", [TotalAmount] * CNY_Rate_1
    )
)

 

  1. Drag the measure into the card visual. The result is shown below.

vjiewumsft_2-1708911643212.png

Best Regards,

Wisdom Wu

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

1 REPLY 1
v-jiewu-msft
Community Support
Community Support

Hi @Setosa ,

Please try the following methods and check if they can solve your problem:

1.Create the simple table.

vjiewumsft_0-1708911576512.png

vjiewumsft_1-1708911598676.png

2.Create the new measure to filter.

 

Rate_1_Equivalent = 
VAR CurrencyAmounts =
    SUMMARIZE(
        FILTER(facttable, facttable[COL] = "abc"),
        facttable[Currency],
        "TotalAmount", SUM(facttable[Amount])
    )

VAR USD_Rate_1 = MAXX(FILTER(slicerTable, slicerTable[Currency] = "usd"), slicerTable[rate_1])
VAR EUR_Rate_1 = MAXX(FILTER(slicerTable, slicerTable[Currency] = "eur"), slicerTable[rate_1])
VAR CNY_Rate_1 = MAXX(FILTER(slicerTable, slicerTable[Currency] = "cny"), slicerTable[rate_1])

RETURN
SUMX(
    CurrencyAmounts,
    SWITCH(
        [Currency],
        "usd", [TotalAmount] * USD_Rate_1,
        "eur", [TotalAmount] * EUR_Rate_1,
        "cny", [TotalAmount] * CNY_Rate_1
    )
)

 

  1. Drag the measure into the card visual. The result is shown below.

vjiewumsft_2-1708911643212.png

Best Regards,

Wisdom Wu

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

 

 

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors