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
charlie_torres
Frequent Visitor

Create a Matrix with Filtered Column Items based on a dynamic date range.

Dear @community,
On the need for help again :[ after reading about many similar situations in the forum, but not quite the intended solution. The current problem is creating a matrix that follows a weekly dynamic date change. The matrix needs to filter the column items (properties) whose date for the respective Milestone achieved lies on the range of dates for the current week.

Please see below mock image of the Milestones table:

charlie_torres_2-1676302298560.png

 

Also an example of the matrix I intend to produce:

charlie_torres_1-1676301968464.png

I got the dynamic dates that will change based on the date of access to the report, to ensure always showing current week records:

 

Week Commencing =
VAR weekComenc =
TODAY() - WEEKDAY( TODAY(), 3)
RETURN
weekComenc

Week Ending =
VAR weekEnd =
TODAY() - WEEKDAY( TODAY(), 3) + 4
RETURN
weekEnd

Plus, the DAX I thought would be the solution if I create this measure for each milestones to later adding them all into the matrix:

EVALUATE( ADDCOLUMNS ( VALUES ( 'Milestones table'[Property] ),
"Current Milestone Date", CALCULATE ( COUNTROWS ( 'Milestones table'), FILTER( 'Milestones table', 'Milestones table'[Pre-Survey Meeting] > 'Milestones table'[Week Comencing] ), FILTER( 'Milestones table', 'Milestones table'[Pre-Survey Meeting] <= 'Milestones table'[Week Ending] )))

 

After trying this one I got error: Multiple columns cannot be converted to a scalar value.

 

As usuall all help, answer or links for a solution are highly appreciated

 

Charlie

1 ACCEPTED SOLUTION

Hi @charlie_torres,

I'd like to suggest you use measure formula to instead the value field to use on matrix.

You can use this formula to lookup raw table records and add a variable to extract the current row context date to use in compare with system date steps.

After these steps, you can use an if statement to check current row context data to prevent the calculation in the not match ranges and move the corresponding expression into the if statements true branch.
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

4 REPLIES 4
charlie_torres
Frequent Visitor

Hi @v-shex-msft,

 

Your suggestion is exactly what I was looking for. It's starting to look accordingly. However, The only obstacle I am finding now is filtering what the matrix displays based on the dynamic range of dates I created. Therefore, this is only shown if a date associated with a building is within range.

 

Any idea how I can accomplish this?

 

Many Thanks
Charlie

Hi @charlie_torres,

I'd like to suggest you use measure formula to instead the value field to use on matrix.

You can use this formula to lookup raw table records and add a variable to extract the current row context date to use in compare with system date steps.

After these steps, you can use an if statement to check current row context data to prevent the calculation in the not match ranges and move the corresponding expression into the if statements true branch.
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft 

 

That was it. It is fully working as expected.

Thank you very much

Regards
Charlie

v-shex-msft
Community Support
Community Support

Hi @charlie_torres,

I'd like to suggest you use unpivot columns feautre on the milestones fields to convert them to attribute and value.

Then you can use the unpivoted attribute on the matrix row, property field on column, the raw table date field on value fields with aggregate(first or last).

Unpivot columns - Power Query | Microsoft Learn

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help 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.