March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello together,
I am struggling with the following problem.
There are two tables: Date and FactSales. The Date table shows the current date and has a mapped date to the previous year. So a simple DATEADD / PREVIOUSYEAR will not work...
I would like to create a matrix visual, which displays the following columns. (Sales PY (previous year) should not be empty)
Using the Selectedvalue function I can successfully map the Date PY to the current date:
However applying the same logic to the Calculate function ends up returning blank results. Anyone knows what I am doing wrong?
Thank you very much
Solved! Go to Solution.
Just add LastYearDate column in Date Table and relate it to fact sale which will be inactive and then use the userrelationship() function to activate it virtualy in measure for PY
PreviousYearSales =
CALCULATE(
SUM(Sales[SalesAmount]),
USERELATIONSHIP('Date'[lastYearDate], Sales[SaleDate])
)
or try @johnt75 DAX
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
Just add LastYearDate column in Date Table and relate it to fact sale which will be inactive and then use the userrelationship() function to activate it virtualy in measure for PY
PreviousYearSales =
CALCULATE(
SUM(Sales[SalesAmount]),
USERELATIONSHIP('Date'[lastYearDate], Sales[SaleDate])
)
or try @johnt75 DAX
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
Make sure that your date table has all the dates for all the years you are interested in, and make sure that it is marked as a date table.
Change the relationship between date and the fact table to single direction.
You can then write the sales PY measure as
Sales PY =
CALCULATE ( SUM ( 'Fact_Sales'[Sales] ), DATEADD ( 'Date'[Date], -1, YEAR ) )
I am not looking for an exact comparison but if you have a look at the calendar table, dates are shifted.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
115 | |
76 | |
57 | |
52 | |
44 |
User | Count |
---|---|
167 | |
117 | |
63 | |
57 | |
50 |