cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jonespossibly
Helper I
Helper I

Dax - find an item in last month's data

I've got data that gets produced on the first of the month and i need to  create a boolean column based on if a particular id in this month was also in the data from last month.

 

how do i go about that?

3 ACCEPTED SOLUTIONS
mhossain
Super User
Super User

@jonespossibly 

 

Assuming you have a Table1 with all the historical and latest data in there, and column name is ID.

COUNTIF for Duplicate IDs =
VAR __ID = Table1[ID]
RETURN
COUNTROWS(
FILTER(
ALL(Table1),
__ID = Table1[ID]
)
)

Hope this is what you are looking for.

View solution in original post

jonespossibly
Helper I
Helper I

ended up using this in the end as i needed the id and extra criteria:

 

var ID = 'table'[id]
var prevMonth = STARTOFMONTH( previousmonth( 'table'[reporting_date]) )
var result = LOOKUPVALUE( 'table'[extraCriteria],
'table'[id], ID,
'table'[reporting_date], prevMonth
)
return result
 
but your answer provided inspiration for it 🙂

View solution in original post

v-caitlyn-mstf
Community Support
Community Support

Hi @jonespossibly ,

 

Glad your problem is solved, can you accept the correct answer as solution, so that other users with similar problems to yours can find the solution faster, thanks in advance!

 

Hope it helps,


Community Support Team _ Caitlyn

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

3 REPLIES 3
v-caitlyn-mstf
Community Support
Community Support

Hi @jonespossibly ,

 

Glad your problem is solved, can you accept the correct answer as solution, so that other users with similar problems to yours can find the solution faster, thanks in advance!

 

Hope it helps,


Community Support Team _ Caitlyn

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

jonespossibly
Helper I
Helper I

ended up using this in the end as i needed the id and extra criteria:

 

var ID = 'table'[id]
var prevMonth = STARTOFMONTH( previousmonth( 'table'[reporting_date]) )
var result = LOOKUPVALUE( 'table'[extraCriteria],
'table'[id], ID,
'table'[reporting_date], prevMonth
)
return result
 
but your answer provided inspiration for it 🙂
mhossain
Super User
Super User

@jonespossibly 

 

Assuming you have a Table1 with all the historical and latest data in there, and column name is ID.

COUNTIF for Duplicate IDs =
VAR __ID = Table1[ID]
RETURN
COUNTROWS(
FILTER(
ALL(Table1),
__ID = Table1[ID]
)
)

Hope this is what you are looking for.

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors