Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
HKIndia
Frequent Visitor

3 weeks start and end date except current week based on weekending slicer

Hi All,

Please help..!

 

Need help with calculating "last3WeeksTotal" based on the selected Weekending date in the slicer. The formula I provided is showing blank results:

 

I have applied below DAX but it showing blank result :- 

3Wkstotal =
CALCULATE(
    SUM('Date_set'[Revenue]),
    FILTER('Date_set',
    'Date_set'[Order Stage] = "Ordered"
    &&'Date_set'[Scope] = "Order"
    ),FILTER('CalendarDate','CalendarDate'[Date]>=[Selected_date]-27 && 'CalendarDate'[Date]<=[Selected_date]-7))

 

Report link below:

https://www.dropbox.com/s/6jvwyryae34ormg/3Weeks%20Total%20issue.pbix?dl=0 

HKIndia_0-1690266652728.png

 

HKIndia_1-1690266712433.png

 

Any suggestions or corrections are welcome!

 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

pls try this

 

3Wkstotal = 
 VAR _dateselected = [Selected_date]
 VAR _Results =//Monday = 2,Tuesday = 3, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7 
CALCULATE(
    SUM('Date_set'[Revenue]),
    ('Date_set'[Order Stage] ,
    'Date_set'[Scope])   in {( "Ordered","Order")}, REMOVEFILTERS(CalendarDate),   DATESBETWEEN('CalendarDate'[Date], _dateselected-27,_dateselected-7))
 RETURN
_Results
-----------------or --------------
3Wkstotal = 
 VAR _dateselected = [Selected_date]
 VAR _Results =//Monday = 2,Tuesday = 3, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7 
CALCULATE(
    SUM('Date_set'[Revenue]),
    ('Date_set'[Order Stage] ,
    'Date_set'[Scope])   in {( "Ordered","Order")},   DATESBETWEEN('CalendarDate'[Date], _dateselected-27,_dateselected-7))
 RETURN
_Results

 

View solution in original post

4 REPLIES 4
Ahmedx
Super User
Super User

pls try this

 

3Wkstotal = 
 VAR _dateselected = [Selected_date]
 VAR _Results =//Monday = 2,Tuesday = 3, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7 
CALCULATE(
    SUM('Date_set'[Revenue]),
    ('Date_set'[Order Stage] ,
    'Date_set'[Scope])   in {( "Ordered","Order")}, REMOVEFILTERS(CalendarDate),   DATESBETWEEN('CalendarDate'[Date], _dateselected-27,_dateselected-7))
 RETURN
_Results
-----------------or --------------
3Wkstotal = 
 VAR _dateselected = [Selected_date]
 VAR _Results =//Monday = 2,Tuesday = 3, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7 
CALCULATE(
    SUM('Date_set'[Revenue]),
    ('Date_set'[Order Stage] ,
    'Date_set'[Scope])   in {( "Ordered","Order")},   DATESBETWEEN('CalendarDate'[Date], _dateselected-27,_dateselected-7))
 RETURN
_Results

 

@Ahmedx  Thank you so much, I am about to accept this as solution however i have just a little query, we are summing revenue currentrly right, but if I want to apply average function. it shows wrong result.

 

HKIndia_1-1690301148697.png

 

How we can achive 4552 when we use Average funtion instead of sum. Please suggest.

 

it's complicated, but try writing another measure like this

fexed =
var _tbl =
SUMMARIZE('Date_set','Date_set'[Business Unit])

RETURN
SUMX(_tbl,[3WksAvgNew])

Thi @Ahmedx  Thank you for replying!

 

But it is showing blank after applying this measure.! as It seems too comlicated. Thanks for trying!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.