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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
iamhuz
Frequent Visitor

Compare MTD with LYMTD Based on Different dates

Hi, I have a Calendar table like below. This table is connected with a Fact Table (Which has Date and Sales)
Scenario: I would like to create two score card, one for MTD and another for LYMTD which will be based on a Calendar date slicer on my report.
Challenge: When I select 25th March, On one card I should see MTD and on another card, I would like to see LYMTD (based on available dates in the LYDate column and note on the calendar date)
Example: LYMTD should only count dates from 02-Mar-22 to 23-March-22 + 02-Apr-222 to 04-Apr-222.
Basically, I want to compare MTD and LYMTD by row and not by dates.
Also, it should be dynamic.

 

iamhuz_0-1680464906897.png

 

3 REPLIES 3
iamhuz
Frequent Visitor

@AllisonKennedy  I tried but the above measure is not working. No, the LYDate can be changed by the business user.

@iamhuz  Sorry for the delay in reply. What does your data model look like? Did you create the inactive relationship first? What about the above measure doesn't work? 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

AllisonKennedy
Super User
Super User

@iamhuz  Is the LYDate unique? You could create an inactive relationship and use USERELATIONSHIP inside a calculate measure:

measure = calculate ( [this year measure], USERELATIONSHIP ( factTable[date], dateTable[LYdate] ) )


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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