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
avulasandeep
Helper III
Helper III

Display the Data , if Date is less than 15th of the Month and Greater than 15th of the Month

HI Experts , 

 

here i  need dax function :

 

if Date is Greater than 15th of this Month i need to display the data of all the month's data till last month and Less than 15th of the Month means i need to display all the month data except last month .

latest dax function.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

any one know this formula or method  let me know .

 

Advance Thanks 

 

Thanks 

sandeep

1 ACCEPTED SOLUTION

Hi,

 

Try this

 

  1. Create a Calendar Table
  2. Create a relationship from the Date column of the Data Table to the Date column of the Calendar Table
  3. Create a slicer visual and drag the Date from the Calendar table to the slicer
  4. Select any one date in the slicer visual
  5. Enter this measure

=CALCULATE(SUM(Data[Sales]),DATESBETWEEN(Calendar[Date],DATE(YEAR(MIN(Calendar[Date])),1,1),IF(DAY(MIN(Calendar[Date]))<15,EOMONTH(MIN(Calendar[Date]),-2),EOMONTH(MIN(Calendar[Date]),-1))))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

 

Could you show your expected result.  In a simple table, what do you want to see in the row labels/column labels and in the value area section.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi 
My Output is like  in below  pic.

 

 

new req 31 may.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

this is the output of the  i want to display ie  

if i selected date is march 14th then output should be the sum(sales) for the month of January.

if i selected date is march 16th then output should be the sum(sales) for the month of January+ Sum(sales) for month of february.

 

 

 

Thanks 

sandeep

Hi,

 

Try this

 

  1. Create a Calendar Table
  2. Create a relationship from the Date column of the Data Table to the Date column of the Calendar Table
  3. Create a slicer visual and drag the Date from the Calendar table to the slicer
  4. Select any one date in the slicer visual
  5. Enter this measure

=CALCULATE(SUM(Data[Sales]),DATESBETWEEN(Calendar[Date],DATE(YEAR(MIN(Calendar[Date])),1,1),IF(DAY(MIN(Calendar[Date]))<15,EOMONTH(MIN(Calendar[Date]),-2),EOMONTH(MIN(Calendar[Date]),-1))))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur,

 

With reference to your post, could you tell me what point number 4 and 5 are saying? . I guessing 5 is to create a measure. But i wasnt clear with 4. Does that mean we just select a value in list date slicer.

 

Thanks

Aj 

Hi,

 

Yes.  Just select one date in the date slicer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

hi!

i too have the same problem but not to display between the date need to display the sale of start date as one column and end date sales as one column

NipponSahore
Resolver II
Resolver II

Please confirm if the Date you're mentioning is the max date in your dataset or do you need a column which cumulatively sums up the sale for for every record. 

Yes Date is the define as the Max date and sales is cummulative sum with respect to given condition ....

If the date is <15 of the month ...data has to display all the months cummulative sum from starting month of the year to till date except last Month

If the date >15 of the month ...data has to display all the months cummulative sum from starting month of the year to till date including last month cummulative sum also .

Thanks
Sandeep

@avulasandeep

 

you could use something like

DAX = 
var MaxDate = max(date)
var startdate = Date(Year(maxDate),"01","01")
return 
if (day(maxDate)<=15, 
Calculate(sum(sales), filter(table,datebetween(date,startdate,EOMONTH(maxDate,-2)))),
Calculate(sum(sales), filter(table,datebetween(date,startdate,EOMONTH(maxDate,-1))))
)


Assuming you want the sum of only 1 year. You can change this by setting the StartDate.
Also assumed for the date of 15th of every month you want the result to be the same as 14th.

 

Let me know if that works out

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.