Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
paulgeorge
Frequent Visitor

Show Status history of Project with NA for missing dates

I have a requirement to show last five week status history (as on friday) of a project (Filtered in page level) like below

20-Jan-2327-Jan-233-Feb-2310-Feb-2317-Feb-23
GreenYellowRed Red

My Status Update table is somehing like this

Status DateStatusProject
16-Jan-23GreenProject 1
19-Jan-23YellowProject 1
16-Jan-23RedProject 2
31-Jan-23GreenProject 1
15-Jan-23RedProject 2


I created a new custom column "Week" to compute the date of Friday of every week

In Report, I need to show the latest report in a week (ex. for Porject 1, I should show status as on 19 Jan 23). I was able to find the latest report by creating a new custom column called 'Latest Weekly Status'

Latest Weekly Report =
VAR LatestDate =
    MAXX (
        FILTER ('Status Update', 'Status Update'[ProjectID] = EARLIER ( 'Status Update'[ProjectID] ) && 'Status Update'[Week] =  EARLIER('Status Update'[Week])),
        'Status Update'[Report Date]
    )
RETURN IF ('Status Update'[Report Date] = LatestDate, 1, 0)

I am filtering the records which has Latest Weekly Report as 1.
I am struggling to show the weeks where there is no status submitted. Based on the above data in Status table the matrix should be shown like below

For Project 1
20-Jan-2327-Jan-233-Feb-2310-Feb-2317-Feb-23
YellowNAGreenNANA

 

and For Project 2

20-Jan-2327-Jan-233-Feb-2310-Feb-2317-Feb-23
RedNANANARed

I created a calendar table with dates and weeks. 
I have the Week and Latest Report Flag in Status Update Table
Can anyone explain for guide me how to use these table and show the report as shown above?
Any suggestions are welcome
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @paulgeorge ,

I created a sample pbix file(see the attachment, please check if that is what you want.

1. Create a separate calendar dimension table(Please DO NOT create any relationship with your fact table)

2. Create a calculated column as below in the calendar table to get the weekdate which is on Friday

Week = 
CALCULATE (
    MIN ( 'Calendar'[Date] ),
    FILTER (
        'Calendar',
        'Calendar'[WeekNum] = EARLIER ( 'Calendar'[WeekNum] )
            && WEEKDAY ( 'Calendar'[Date], 2 ) = 5
    )
)

3. Create a measure as below to get the status

Measure = 
VAR _selweek =
    SELECTEDVALUE ( 'Calendar'[Week] )
VAR _selweeknum =
    WEEKNUM ( _selweek, 2 )
VAR _mindate =
    CALCULATE (
        MIN ( 'Calendar'[Date] ),
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            YEAR ( 'Calendar'[Date] ) = YEAR ( _selweek )
                && 'Calendar'[WeekNum] = _selweeknum
        )
    )
VAR _maxdate =
    CALCULATE (
        MAX ( 'Calendar'[Date] ),
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            YEAR ( 'Calendar'[Date] ) = YEAR ( _selweek )
                && 'Calendar'[WeekNum] = _selweeknum
        )
    )
VAR _status =
    CALCULATE (
        MAX ( 'Table'[Status] ),
        FILTER (
            'Table',
            'Table'[Status Date] >= _mindate
                && 'Table'[Status Date] <= _maxdate
        )
    )
RETURN
    _status

yingyinr_0-1677054753957.png

Best Regards

Community Support Team _ Rena
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-yiruan-msft
Community Support
Community Support

Hi @paulgeorge ,

I created a sample pbix file(see the attachment, please check if that is what you want.

1. Create a separate calendar dimension table(Please DO NOT create any relationship with your fact table)

2. Create a calculated column as below in the calendar table to get the weekdate which is on Friday

Week = 
CALCULATE (
    MIN ( 'Calendar'[Date] ),
    FILTER (
        'Calendar',
        'Calendar'[WeekNum] = EARLIER ( 'Calendar'[WeekNum] )
            && WEEKDAY ( 'Calendar'[Date], 2 ) = 5
    )
)

3. Create a measure as below to get the status

Measure = 
VAR _selweek =
    SELECTEDVALUE ( 'Calendar'[Week] )
VAR _selweeknum =
    WEEKNUM ( _selweek, 2 )
VAR _mindate =
    CALCULATE (
        MIN ( 'Calendar'[Date] ),
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            YEAR ( 'Calendar'[Date] ) = YEAR ( _selweek )
                && 'Calendar'[WeekNum] = _selweeknum
        )
    )
VAR _maxdate =
    CALCULATE (
        MAX ( 'Calendar'[Date] ),
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            YEAR ( 'Calendar'[Date] ) = YEAR ( _selweek )
                && 'Calendar'[WeekNum] = _selweeknum
        )
    )
VAR _status =
    CALCULATE (
        MAX ( 'Table'[Status] ),
        FILTER (
            'Table',
            'Table'[Status Date] >= _mindate
                && 'Table'[Status Date] <= _maxdate
        )
    )
RETURN
    _status

yingyinr_0-1677054753957.png

Best Regards

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.