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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
matsahiro
Helper II
Helper II

DAX Calculating on Wrong Rows - Not Recognizing Join Relationship Properly

Hello, I'm trying to figure out why DAX isn't calculating properly on the right rows. I have this indicator made in DAX trying to show which accounts have different dates from previous and current data. For some reason, although each account has specific dates associated it, Power BI is matching all the dates with all the accounts and calculating on that. When what I want it to do is only calculate on accounts that have the corresponding dates. 

 

New_Date_Indicator = IF(SELECTEDVALUE('Current'[Statement Date])=SELECTEDVALUE(Previous[Previous Statement Date]),"0","1")

matsahiro_0-1613519822006.png

 

Current visual looks like this, but it is wrong, as it is not matching account with date properly.

 

matsahiro_1-1613519274550.png

matsahiro_2-1613519298754.png

I've established a 1 to 1 relationship joining on Account.

 

 
8 REPLIES 8
jameszhang0805
Resolver IV
Resolver IV

@matsahiro  
If I understand correctly, you are trying to find accounts with the same current date as the previous date,
then to calculate some expressions based on the filtered results. 
So in your sample, Bob and Pat need to be screened out.
Virtual data source:

jameszhang0805_0-1613809507091.png

Result:

jameszhang0805_1-1613809704622.png

My solution is based on having a common account table and joining two other tables in a one-to-many relationship
Find out account which Current Date equal to Previous Date.pbix 

 

I ended up merging the two data tables on account name in query editor. Thank you for your help!

 

Welcome, that's my pleasure. I know you have solved the problem by yourself.
I just wanted to update the method of not having to build a common table and without relationships.

CorrectAccoutAmt = 
VAR _CurrentTable =
    CALCULATETABLE (
        SUMMARIZE ( 'Current', 'Current'[Statement Date], 'Current'[Account] ),
        ALLSELECTED ()
    )
VAR _PreviousTable =
    CALCULATETABLE (
        SUMMARIZE ( 'Previous', Previous[Previous Date], 'Previous'[Account] ),
        ALLSELECTED ()
    )
VAR _CorrectAccount =
    INTERSECT ( _CurrentTable, _PreviousTable )
VAR _Result =
    CALCULATE (
        SUM ( 'Current'[Amount] ),
        KEEPFILTERS ( _CorrectAccount )
    )
RETURN
    _Result
amitchandak
Super User
Super User

@matsahiro , You need to have a common account table and join these two tables with that. and analyze with the account numbers from the common table.

 

You can create a measure like

New_Date_Indicator = IF(max('Current'[Statement Date])=max(Previous[Previous Statement Date]),"0","1")

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

@amitchandak I went ahead and created the common account table and added indexes to the other two tables. I joined on the indexes with ID in account table. Here's what the relationship looks like. 

matsahiro_0-1613577822785.png

The relationships looks to be right until I add in the indicator. 

matsahiro_1-1613577871023.pngmatsahiro_2-1613577903104.png

 

matsahiro_3-1613578487171.png

 

@matsahiro , Make these 1-1 Join as 1-M (account is 1), single direction and try 

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

matsahiro_0-1613579221338.png

Unfortunately when I establish the relationships like that, the visual breaks even without the indicator included in the visual. 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.