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.
if current week sale is empty then need to calculate sales for the last non empty week sales. (for example if the current week is week number 5 and it doesnot have any sales data and week 2 does then i want it to show week 2 sales )
used following measure to calculate currweek sale:
payment currweek = CALCULATE(SUM('Table 3'[Payment]),FILTER(tbl_Calendar_ph,YEAR(tbl_Calendar_ph[Date])=YEAR(NOW())&&WEEKNUM(NOW())=tbl_Calendar_ph[Week Number]))
(PAYMENT IS SALES)
need something similar for previous week sales also
THANKS for help.
Solved! Go to Solution.
You could use the last sale date instead of NOW().
Try this:
payment currweek =
VAR LastSaleDate =
CALCULATE (
MAX ( tbl_Calendar_ph[Date] ),
FILTER ( tbl_Calendar_ph, CALCULATE ( SUM ( 'Table 3'[Payment] ) ) > 0 )
)
RETURN
CALCULATE (
SUM ( 'Table 3'[Payment] ),
FILTER (
tbl_Calendar_ph,
YEAR ( tbl_Calendar_ph[Date] ) = YEAR ( LastSaleDate )
&& WEEKNUM ( LastSaleDate ) = tbl_Calendar_ph[Week Number]
)
)
You could use the last sale date instead of NOW().
Try this:
payment currweek =
VAR LastSaleDate =
CALCULATE (
MAX ( tbl_Calendar_ph[Date] ),
FILTER ( tbl_Calendar_ph, CALCULATE ( SUM ( 'Table 3'[Payment] ) ) > 0 )
)
RETURN
CALCULATE (
SUM ( 'Table 3'[Payment] ),
FILTER (
tbl_Calendar_ph,
YEAR ( tbl_Calendar_ph[Date] ) = YEAR ( LastSaleDate )
&& WEEKNUM ( LastSaleDate ) = tbl_Calendar_ph[Week Number]
)
)
can i get same logic for previous week?
Try appending " - 7" to the LastSaleDate variable.
YOU ARE THE BEST
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 |
---|---|
47 | |
24 | |
20 | |
15 | |
13 |
User | Count |
---|---|
51 | |
46 | |
39 | |
19 | |
19 |