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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Krishna_14hcl
Frequent Visitor

dynamically Data from Two table using slicer in card

Dear All,

I am very new in power BI therefore need a favour in dax, Please help me to create a Dax, 
I have two data sets table 1 & table 2 as given below. The requirement is total sales USD 2000 from table 1, but when we use slicer for counry values should be pick up from table 2. i.e Canada  500, Russia 200 and Germany 300. Please help me to get this in a card in power BI. 

 

Table 1  Table 2 
Country nameSales CountrySales
USA690 Canada500
India780 Russia200
Canada340 Germany300
Russia30   
Germany160   
Total Sales2000   
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Krishna_14hcl 

 

I created a measure and replaced the data from Table1 with the data for the Table2 country, as shown in the following image

 

vyohuamsft_0-1708677404509.png

 

Here is the DAX:

Dynamic Sales =
VAR SelectedCountry =
    SELECTEDVALUE ( 'Table2'[Country], "All" )
RETURN
    IF (
        SelectedCountry = "All",
        SUMX ( 'Table1', 'Table1'[Sales1] ),
        CALCULATE ( SUM ( 'Table2'[Sales] ), 'Table2'[Country] = SelectedCountry )
    )

 

Then create a measure to calculate the totals for Table1

 

1.png

DAX:

Dynamic Sales Total = SUMX('Table1','Table1'[Dynamic Sales])

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)

Best Regards

Yongkang Hua

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

4 REPLIES 4
Anonymous
Not applicable

Hi, @Krishna_14hcl 

 

I created a measure and replaced the data from Table1 with the data for the Table2 country, as shown in the following image

 

vyohuamsft_0-1708677404509.png

 

Here is the DAX:

Dynamic Sales =
VAR SelectedCountry =
    SELECTEDVALUE ( 'Table2'[Country], "All" )
RETURN
    IF (
        SelectedCountry = "All",
        SUMX ( 'Table1', 'Table1'[Sales1] ),
        CALCULATE ( SUM ( 'Table2'[Sales] ), 'Table2'[Country] = SelectedCountry )
    )

 

Then create a measure to calculate the totals for Table1

 

1.png

DAX:

Dynamic Sales Total = SUMX('Table1','Table1'[Dynamic Sales])

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)

Best Regards

Yongkang Hua

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

 

Krishna_14hcl
Frequent Visitor

Dear Syk,


thanks for sharing your guidance, But the condition is some different, As per requirement. I need to show Total sales in a card from the  first table of country name, but when I use slicer , it should filter data  from second table like 
country name canada is 500 as actual value, instead of canada (340 that is some overlap sales) because in first table some data is overlapping with some criteria.

Is it possible to show the data from other table using selectedvalue and switch like measures if yes, Please help

Possibly.. But your data would get messy and hard to understand very quickly. Is the requirement that if there is data in table 2 for a country, you no longer need the data from table 1? If there's no data in table 2, use the data from table 1?

Syk
Resident Rockstar
Resident Rockstar

If the data is the same, you should combine these into 1 table. Use the append query option to do this. If the "Total Sales" is an actual row in your data, remove it.

Syk_0-1708609847587.png

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.