The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I need your help on below.
I have two tables, a date table and fact table.
I'd like to implement a simple (custom) YTD logic to sum up YTD sales.
See below formula.
The formula is giving me the right results, but then when I try for example to drag in the calendar date to see details by date, the table remains blank.
What am I doing wrong?
I hope you can help.
Best,
P.
Solved! Go to Solution.
Hi,
thanks for your reply.
It almost worked. In the end the following code did the trick. I added another ALLSELECTED and then it worked. I cannot explain exactly why, but am happy 🙂
Best,
P
YTD =
CALCULATE (
SELECTEDMEASURE (),
ALLSELECTED ( Calendar_day ),
FILTER (
Calendar_day,
AND (
Calendar_day[Calendar_day.Commercial Year]
= CALCULATE (
MAX ( Calendar_day[Calendar_day.Commercial Year] ),
FILTER (
ALL ( Calendar_day ),
Calendar_day[Calendar_day.Calendar Date] = TODAY ()
)
),
Calendar_day[Calendar_day.Commercial Year_Week]
<= CALCULATE (
MAX ( Calendar_day[Calendar_day.Commercial Year_Week] ),
FILTER (
ALL ( Calendar_day ),
Calendar_day[Calendar_day.Calendar Date] = TODAY ()
)
)
)
)
)
Hi @PhMeDie ,
We can try to use the following measure to meet your requirement:
Sales YTD =
CALCULATE (
SUM ( 'Table'[Sales Quantity] ),
FILTER (
Calendar_day,
AND (
Calendar_day[Calendar_day.Commercial Year]
= CALCULATE (
MAX ( Calendar_day[Calendar_day.Commercial Year] ),
FILTER (
ALLSELECTED ( Calendar_day ),
Calendar_day[Calendar_day.Calendar Date] = TODAY ()
)
),
Calendar_day[Calendar_day.Commercial Year_Week]
<= CALCULATE (
MAX ( Calendar_day[Calendar_day.Commercial Year_Week] ),
FILTER (
ALLSELECTED ( Calendar_day ),
Calendar_day[Calendar_day.Calendar Date] = TODAY ()
)
)
)
)
)
If it doesn't meet your requirement, kindly share your sample data and expected result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.
Best regards,
Hi,
thanks for your reply.
It almost worked. In the end the following code did the trick. I added another ALLSELECTED and then it worked. I cannot explain exactly why, but am happy 🙂
Best,
P
YTD =
CALCULATE (
SELECTEDMEASURE (),
ALLSELECTED ( Calendar_day ),
FILTER (
Calendar_day,
AND (
Calendar_day[Calendar_day.Commercial Year]
= CALCULATE (
MAX ( Calendar_day[Calendar_day.Commercial Year] ),
FILTER (
ALL ( Calendar_day ),
Calendar_day[Calendar_day.Calendar Date] = TODAY ()
)
),
Calendar_day[Calendar_day.Commercial Year_Week]
<= CALCULATE (
MAX ( Calendar_day[Calendar_day.Commercial Year_Week] ),
FILTER (
ALL ( Calendar_day ),
Calendar_day[Calendar_day.Calendar Date] = TODAY ()
)
)
)
)
)