cancel
Showing results for
Did you mean:
Helper III

## Calculate sales based on selected date

Hi all,

I am stucked while calculating sales with different conditions. Let me explain in detail

I have a calendar table and a Sales table, and looking for a dax where if i am selecting any date using calendar date which is not equal to current data then the dax should calculate sales where the selected date should  less than or equal to posting date and selected date is greater than Clearing date.  and Condition type = BSAD (Note:- Posting date & Clearing date & Condition Type are 3 different columns in Sales Table).

1 ACCEPTED SOLUTION
Super User

@jay_patel , Try a measure like

Measure =
var _max = maxx(allselected('Date1'),'Date1'[Date])
var _m = Calculate(sum(Table[Value]), filter(Table, Table[Posting Date] >=_max && Table[Cleaning Date] <=_max && [Condition type] = "BSAD"))
return
if(isblank(sum(Table[Value])), _m, sum(Table[Value]))

or

If date tble is joined
Measure =
var _max = maxx(allselected('Date1'),'Date1'[Date])
var _m = Calculate(sum(Table[Value]), filter(all(Table), Table[Posting Date] >=_max && Table[Cleaning Date] <=_max && [Condition type] = "BSAD"))
return
if(isblank(sum(Table[Value])), _m, sum(Table[Value]))

Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!
2 REPLIES 2
Anonymous
Not applicable

Hi jay,

now i am facing same issue with vendors data,

(Hi all,

I am stucked while calculating sales with different conditions. Let me explain in detail

I have a calendar table and a Sales table, and looking for a dax where if i am selecting any date using calendar date which is not equal to current data then the dax should calculate sales where the selected date should  less than or equal to posting date and selected date is greater than Clearing date.  and Condition type = BSAD (Note:- Posting date & Clearing date & Condition Type are 3 different columns in Sales Table).)

Super User

@jay_patel , Try a measure like

Measure =
var _max = maxx(allselected('Date1'),'Date1'[Date])
var _m = Calculate(sum(Table[Value]), filter(Table, Table[Posting Date] >=_max && Table[Cleaning Date] <=_max && [Condition type] = "BSAD"))
return
if(isblank(sum(Table[Value])), _m, sum(Table[Value]))

or

If date tble is joined
Measure =
var _max = maxx(allselected('Date1'),'Date1'[Date])
var _m = Calculate(sum(Table[Value]), filter(all(Table), Table[Posting Date] >=_max && Table[Cleaning Date] <=_max && [Condition type] = "BSAD"))
return
if(isblank(sum(Table[Value])), _m, sum(Table[Value]))

Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Announcements

#### Check it Out!

Mark your calendars and join us on Thursday, August 25 at 11a PDT for a great session with Ted Pattison!

#### The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.