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
Sdhn420
Helper IV
Helper IV

Matrix Query

How can i show data in matrix from last day of previous year, last day of previous month in current year and last 3 days of current month. 

 

Example: (if today is 18.02.2021)

 

31.12.2019    -        31.12.2020   -   31.01.2021       - 15.02.2021          - 16.02.2021         - 17.02.2021

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Sdhn420 ,

 

You will need to create several measures for these values.

measure1 = calculate([value],filter(table,date = date(year(today()),1,1) -1))

measure2 = calculate([value],filter(table,date = IF(MONTH(TODAY())=1,DATE(YEAR(TODAY()),1,1),date(year(today()),1,1) -1)))

measure3 = measure2 = calculate([value],filter(table,date <=DATE(YEAR(TODAY()),MONTH(TODAY())+1,1)-1&&date>DATE(YEAR(TODAY()),MONTH(TODAY())+1,1)-3))

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

Hi @Sdhn420 ,

 

You will need to create several measures for these values.

measure1 = calculate([value],filter(table,date = date(year(today()),1,1) -1))

measure2 = calculate([value],filter(table,date = IF(MONTH(TODAY())=1,DATE(YEAR(TODAY()),1,1),date(year(today()),1,1) -1)))

measure3 = measure2 = calculate([value],filter(table,date <=DATE(YEAR(TODAY()),MONTH(TODAY())+1,1)-1&&date>DATE(YEAR(TODAY()),MONTH(TODAY())+1,1)-3))

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@Sdhn420 ,  Try a measure like

Measure =

var _d1 = date(year(today())-1,1,1) -1
var _d2 = date(year(today()),1,1) -1
var _d3 = eomonth(today(),0)
return
calculate([measure] , filter(Table,( Table[Date] = _d1 || Table[Date] = _d2 || Table[Date] = _d3) || (Table[Date] >=today() -2 && Table[Date] <=today()) ))

 

How can I get last day of previous year?

@Sdhn420 ,

Measure =

var _d1 = date(year(today())-1,1,1) -1 //last to last year last day
var _d2 = date(year(today()),1,1) -1 //last day or previous year ; -1 from Jan 1
var _d3 = eomonth(today(),0) //This Month End
return
calculate([measure] , filter(Table,( Table[Date] = _d1 || Table[Date] = _d2 || Table[Date] = _d3) || (Table[Date] >=today() -2 && Table[Date] <=today()) ))

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.