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
BSM1985
Helper IV
Helper IV

Calculations using 2 datasets(tables)

Hi Team,

 

I've 2 tables (datasets) as shown below and I would like to have the calculation from the 2 datasets as below:

 

2 DataSets.PNG

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

Hi, @BSM1985 

It’s my pleasure to answer for you.

If you just want to group by columnA, and add up to get the number that meets the two conditions (columnA=column1 and columnc="Q"),

Like this:

v-janeyg-msft_0-1601455403699.png

You can try it(First, create the relationship between the two tables):

Measure:

Qnumbers =
COUNTROWS (
    FILTER (
        DATASET1,
        AND (
            DATASET1[COLUMNA] = RELATED ( DATASET2[COLUMN1] ),
            DATASET1[COLUMNC] = "Q"
        )
    )
)

If it doesn’t meet your requirements, could you please share what your expected results and share some sample data ?

 

Best Regards

Janey Guo

 

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
v-janeyg-msft
Community Support
Community Support

Hi, @BSM1985 

It’s my pleasure to answer for you.

If you just want to group by columnA, and add up to get the number that meets the two conditions (columnA=column1 and columnc="Q"),

Like this:

v-janeyg-msft_0-1601455403699.png

You can try it(First, create the relationship between the two tables):

Measure:

Qnumbers =
COUNTROWS (
    FILTER (
        DATASET1,
        AND (
            DATASET1[COLUMNA] = RELATED ( DATASET2[COLUMN1] ),
            DATASET1[COLUMNC] = "Q"
        )
    )
)

If it doesn’t meet your requirements, could you please share what your expected results and share some sample data ?

 

Best Regards

Janey Guo

 

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

amitchandak
Super User
Super User

@BSM1985 ,

Column in Dataset 1

Sumx( filter([Data Set2], [Data Set1].[ColumnA] =[Data Set2].[ColumnA] && [Data Set1].[ColumnC] ="Q" ), [ColumnA])

 

A column in Dataset 2

Sumx( filter([Data Set1], [Data Set1].[ColumnA] =[Data Set2].[Column1] && [Data Set1].[ColumnC] ="Q" ), [Column1])

 

Measure

Sumx( filter([Data Set1], [Data Set1].[ColumnA] = max([Data Set2].[Column1]) && [Data Set1].[ColumnC] ="Q" ), [Column1])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

 

Sorry for repeated questions on this, I see the below error message when I implemented the first calculation

Sumx( filter([Data Set2], [Data Set1].[ColumnA] =[Data Set2].[ColumnA] && [Data Set1].[ColumnC] ="Q" ), [ColumnA])

 

"The function SUMX cannot work with typs of values string"

 

My Coulmn A is of string type. Could you advice?

Hello @amitchandak ,

Thanks for your time as always.

 

I also have the OVER PARTITIO BY clause as higlighted below..kindly guide me how to fit this in your calculation

 

SUM
(
IF [Dataset1].[COLUMN A]=[Dataset2].[COLUMN 1] AND [Dataset1].[COLUMN C]="Q"

THEN1 ELSE 0 END

)
OVER PARTITION BY [Dataset1].[COLUMN A]

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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