Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi DAX experts,
For "Sales $ Last year to date" measure, my requirement is that if no date is selected/filtered, the period of calculating "Sales $ LYTD" is from beginning of previous year to yesterday's date of previous year. e.g: today is 6th Sep; the perios is from 2016-01-01 to 2016-09-05. My DAX is as followings. I use isfiltered function to check if date is filtered and use different calculation to calculate Sales $ LYTD. It worked fine before. After we removed some data from fact table, full process the tabular cube and the "Sales $ LYTD" become wrong.
Sales $ LYTD:=
var yesterday= CALCULATE(max('Date'[Date]),filter(all('Date'),'Date'[Day Offset]=0))
if(ISFILTERED('Date'[Year]) || ISFILTERED('Date'[Month Desc]) || ISFILTERED('Date'[Day Desc]),
CALCULATE([Sales $],dateadd(DATESYTD('Date'[Date]),-1,YEAR)),
CALCULATE(
[Sales $],
filter(
all('Date'),
'Date'[Year]=year(yesterday)-1 && 'Date'[Month Number]<=month(yesterday) && 'Date'[Day Number]<=day(yesterday)
)
)
)
if I filter on date and select a date 2017-09-05, it works perfectly. see below screenshot:
If I don't filter on the date, it is wrong. See below screenshot:
if I break down the data slicing by region dim, I found subtotal on region level is wrong, the grandtotal just the sum of subtotal, which is wrong either.
if I break down the year, the grand total is wrong:
note: I have debugged my filter "'Date'[Year]=year(yesterday)-1 && 'Date'[Month Number]<=month(yesterday) && 'Date'[Day Number]<=day(yesterday)", it is as expected.
Can you please advise the root cause and what is further troubleshoting steps I can do? Thank you.
Solved! Go to Solution.
I have found the root cause by myself. My below condition has logic mistake to get correct period. issue resolved now
'Date'[Year]=year(yesterday)-1 && 'Date'[Month Number]<=month(yesterday) && 'Date'[Day Number]<=day(yesterday)
I have found the root cause by myself. My below condition has logic mistake to get correct period. issue resolved now
'Date'[Year]=year(yesterday)-1 && 'Date'[Month Number]<=month(yesterday) && 'Date'[Day Number]<=day(yesterday)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
85 | |
67 | |
59 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |