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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Hong_HW
Frequent Visitor

Need help on filter dax

Hi,

I'll need some help on the dax formula.

 

I have 2 tables below

Table 1 named Country with 2 columns

Country rollupHub
CTYCTY
THASEAN
MYASEAN
CNNASIA
HKNASIA

 

Table 2 named Sales Amt

CountryUSD
PH300
MY200
CN150
HK200

 

In my PBI, i have the country as the filter, now i want to create a table to return the corresponding sales amount by selecting the options from the country filter.

 

i.e Select CTY, return 850 ( which is the sum of SG+MY+CN+HK)

    Select ASEAN, result table return 500 (which is the sum of PH+MY)

    Select NASIA, result table return 350 (which is the sum of CN+HK)

    Select PH, only return 300;

 

Much appreciate it.

 

Thank you

Regards

Hazel

 

1 ACCEPTED SOLUTION

hi @Hong_HW 

Try like:
Measure =
IF(
   SELECTEDVALUE(Table1[Country]) = "CTY",
   SUMX(ALL(Table2),Table2[USD]),
   SUM(Table2[USD])
)

View solution in original post

6 REPLIES 6
Hong_HW
Frequent Visitor

Some add on information

 

Table 1 

Hong_HW_0-1677235336713.png

 

Table 2

Hong_HW_1-1677235387660.png

 

Currently when i select the individual country, the sales amount is showing up.

But when i select CTY, the sales amount is showing blank.  I'm not sure if there is any dax could help me to sum up the sales amount from all countries? Much appreciate it.

 

Hong_HW_2-1677235582285.png

 

 

Hong_HW_3-1677235616774.png

hi @Hong_HW 

Try like:
Measure =
IF(
   SELECTEDVALUE(Table1[Country]) = "CTY",
   SUMX(ALL(Table2),Table2[USD]),
   SUM(Table2[USD])
)

Thank you very much, it works 👍.

 

I've tried the following formula, but it doesn't work. Not sure what is the issue.  It will be much appreated if you could advise too?

 

Test Measure 1 =
VAR SelectedCountry = SELECTEDVALUE('Table 1'[Country rollup])
VAR SelectedHub = SELECTEDVALUE('Table 1'[Hub])

RETURN
IF(
SelectedHub = "CTY",
CALCULATE(
SUM('Table 2'[Amount]),'Table 2'[Country] in {"PH","MY","CN","HK"}),

CALCULATE(
SUM('Table 2'[Amount]),
'Table 2'[Country] = SelectedCountry)
)

hi @Hong_HW 

it seems, this part:

 

SelectedHub = "CTY",
CALCULATE(
SUM('Table 2'[Amount]),'Table 2'[Country] in {"PH","MY","CN","HK"})

 

will return blank, as there is no row where hub is CTY and country is any of "PH","MY","CN","HK".

FreemanZ
Super User
Super User

hi @Hong_HW 

in table1, is TH actually PH?

What does CTY mean? (The others stand for countries or regions)

ASEAN and NASIA are not countries, so they could not in the same column as PH, right?

oh, yes there is typo , TH is actually PH.

CTY means for all countries sum up

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.