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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
jonespossibly
Advocate I
Advocate 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
Solution Sage
Solution Sage

@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
Advocate I
Advocate 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-xiaoyan-msft
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-xiaoyan-msft
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
Advocate I
Advocate 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
Solution Sage
Solution Sage

@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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.