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

DAX Datesbetween Date and Last 10 weeks, Count STATUS="green"

 Hi everybody, i need your help with dax:

 

i have a one year data with weekly Analysis Date. So it's a historical data weekly backed up. Each analysis date is the first day of the week.

-i need to count how many persons with Status="green" were there in the last 10 weeks in each Analysis Date.

 

so today: go back of 10 weeks and count how many persons had Status="ok" in the period today and minus 10 weeks

17 of june: go back of 10 weeks and count how many persons had Status="ok" in the period 17 june and minus 10 weeks

 

i want to have this information per each analysis date. So not exactly 10 weeks ago, but in all the Analysis Dates between 10 weeks ago and the Analysis date

 

Any suggestion ?

 

Columns:
ANALYSIS DATE(each monday of the week;, PERSON(id of person);  STATUS(red, green,amber)

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@Giavo,

Create a new table using dax below.

Table = CALCULATETABLE(YourTable,YourTable[STATUS]="green")

Then in the new table, create the following column and measure.

Column  = DATE(YEAR('Table'[ANALYSIS DATE]),MONTH('Table'[ANALYSIS DATE]),DAY('Table'[ANALYSIS DATE])-70)

Measure  = CALCULATE(COUNTA('Table'[PERSON]),DATESBETWEEN('Table'[ANALYSIS DATE],MAX('Table'[Column]),MAX('Table'[ANALYSIS DATE])))

At last, create a table visual using date field and measure of the new table.

Regards,
Lydia

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

View solution in original post

1 REPLY 1
v-yuezhe-msft
Employee
Employee

@Giavo,

Create a new table using dax below.

Table = CALCULATETABLE(YourTable,YourTable[STATUS]="green")

Then in the new table, create the following column and measure.

Column  = DATE(YEAR('Table'[ANALYSIS DATE]),MONTH('Table'[ANALYSIS DATE]),DAY('Table'[ANALYSIS DATE])-70)

Measure  = CALCULATE(COUNTA('Table'[PERSON]),DATESBETWEEN('Table'[ANALYSIS DATE],MAX('Table'[Column]),MAX('Table'[ANALYSIS DATE])))

At last, create a table visual using date field and measure of the new table.

Regards,
Lydia

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

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.