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.
Hello everyone,
I have a formula to compute last year sales (same weekday so for example for the 1st of January 2018, you get sales from the 2nd of January 2017) which works great:
Sales Last Year Same weekday =
SUMX (
VALUES ( 'Calendar'[DWY] ),
CALCULATE (
SUM ( 'Sales & Tickets'[Sales] ),
FILTER ( ALL ( 'Calendar' ), 'Calendar'[DWY] = EARLIER ( Calendar[DWY] ) - 1 )
)
)
I want add a condition that only allows to compute sales last year if the sales of the day are >700:
FILTER ( ALLSELECTED('Calendar'), SUM ( 'Sales & Tickets'[Sales] ) > 700 )
so which gives as a complete formula:
Sales Last Year Same weekday =
SUMX (
VALUES ( 'Calendar'[DWY] ),
CALCULATE (
SUM ( 'Sales & Tickets'[Sales] ),
FILTER ( ALLSELECTED('Calendar'), SUM ( 'Sales & Tickets'[Sales] ) > 700 ),
FILTER ( ALL ( 'Calendar' ), 'Calendar'[DWY] = EARLIER ( Calendar[DWY] ) - 1 )
)
)
but it does not work (returns a blank). I also tried the following:
Sales Last Year Same weekday =
IF (
SUMX (
VALUES ( 'Calendar'[DWY] ),
CALCULATE (
SUM ( 'Sales & Tickets'[Sales] ),
FILTER (
ALLSELECTED ( 'Calendar' ),
'Calendar'[DWY] = EARLIER ( 'Calendar'[DWY] )
)
)
)
> 700,
SUMX (
VALUES ( 'Calendar'[DWY] ),
CALCULATE (
SUM ( 'Sales & Tickets'[Sales] ),
FILTER ( ALL ( 'Calendar' ), 'Calendar'[DWY] = EARLIER ( Calendar[DWY] ) - 1 )
)
),
BLANK ()
)
but it returns the sales of the full year 2017 instead of Jan-Apr 2017
If anyone has a clue, it would help me quite a bit!
Solved! Go to Solution.
Hi rlebeau,
When column are your slicer based on? You can use
ALLSELECTED(Table[Column])
instead of
ALLSELECTED(Table)
and try again.
Regards,
Jimmy Tao
Hi rlebeau,
When column are your slicer based on? You can use
ALLSELECTED(Table[Column])
instead of
ALLSELECTED(Table)
and try again.
Regards,
Jimmy Tao
Hi @v-yuta-msft,
Thanks for the reply.
Thank you for your comment I realized I was maybe using the wrong table/column.
I was using dates from the master calendar instead of the ones from my sales table.
Anyway, thank you for your comment it worked.
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 |
---|---|
115 | |
99 | |
86 | |
70 | |
62 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |