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
poojag820
Helper I
Helper I

show data from diff table based on key made of col A and Col B against month column

I need to show data into table A from table B based on Key made of Col A and Col B (ColA&ColB). This data into table A from table B is being mapped based on the Key irrespective of any date but need to show against Month column( whatever month is selected)

I am using below dax 

Sales =
VAR _selectedKey = VALUES(tableA[Key])
VAR _salesSum = CALCULATE(
    CALCULATE(
        SUM(tableB[Sales]),
        ) ,
    FILTER(
        ALL(TableB),
        TableB[Key] IN _selectedKey
    )
)
RETURN
_salesSum
 
This is working fine for single month selection, but total not working for multiple month selection. I think this is happening as  I have not used any date col in key but data is being shown againset month col.  any help is appreciated. 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @poojag820 

You can try to create an inactive relationship between the two tables based on the Key field and activate it when it is used.

 

vyaningymsft_0-1725430881648.png

vyaningymsft_1-1725430894693.png

Sales by YearMonth = 
VAR __tableAKey =
    SELECTEDVALUE ( TableA[Key] )
VAR __result =
    CALCULATE (
        SUM ( TableB[Sales] ),
        FILTER ( TableB, TableB[Key] = __tableAKey ),
        RELATEDTABLE ( TableB )
    )
RETURN
    __result


Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

 

View solution in original post

3 REPLIES 3
rajendraongole1
Super User
Super User

Hi @poojag820 -you can adjust your DAX measure to work for both single and multiple month selections

 

Sales =
VAR _selectedKey = VALUES(tableA[Key])
VAR _salesSum =
CALCULATE(
SUM(tableB[Sales]),
FILTER(
ALL(TableB),
TableB[Key] IN _selectedKey &&
TableB[Month] IN VALUES(tableA[Month]) -- Match the Month context
)
)
RETURN
_salesSum

 

Hope this works.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





this condition will map values corresponding to Date also but I need to map values irrespective of date from table B into table A and show it in front of month of Table A.

I am mapping values with Key which does not have date in it. 

Anonymous
Not applicable

Hi, @poojag820 

You can try to create an inactive relationship between the two tables based on the Key field and activate it when it is used.

 

vyaningymsft_0-1725430881648.png

vyaningymsft_1-1725430894693.png

Sales by YearMonth = 
VAR __tableAKey =
    SELECTEDVALUE ( TableA[Key] )
VAR __result =
    CALCULATE (
        SUM ( TableB[Sales] ),
        FILTER ( TableB, TableB[Key] = __tableAKey ),
        RELATEDTABLE ( TableB )
    )
RETURN
    __result


Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

 

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!

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.