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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Help with DAX forumula

I have the following table

 

DateTransactionDateForecastAmountType
01/01/201003/01/2010100A

 

I want to show the Amount where there is a lag of 2 months and the type  = A.

 

The SQL for this would be (but I'm not sure what the DAX would be):

 

SELECT Amount from table

WHERE 

Datetransaction = Dateadd(month,2,DateForecast)

and type = 'A'

3 REPLIES 3
amitchandak
Super User
Super User

Try like

measure =
calculate(sum(Table[Amount]), filter(all(Table),DATEDIFF(Table[DateTransaction],Table[DateForecast],Month)>=2 && Table[Type] ="A"))
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
az38
Community Champion
Community Champion

Hi @Anonymous 

or create a new table

NewTable = 
FILTER(ALL(Table),
DATEDIFF(Table[DateTransaction], Table[DateForecast], MONTH) = 2 && Table[Type] = "A"
)

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Pragati11
Super User
Super User

Hi @Anonymous ,

 

You can create a column in your data and use it as flag on your report:

IsAmountBasedOnLag = IF( table[Datetransaction] = DATEADD(table[DateForecast], 2, month), table[Amount] && table[Type] = "A", 1, 0)

 

The above dax expression creates a flag with 1 or 0 values in it. If your condition is met it is 1, esle it is 0.

On you report, add a report level filter for IsAmountBasedOnLag = 1. This will display relevant details as required.

NOTE: Replace table in above DAX with your table name.

 

If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.