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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors