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
Mido99
New Member

Plotting numbers on Matrix Visual with if statement

Hi,

I’m trying to build to custom “Gantt Chart” as shown below using the native Matrix visual (do not want to use external visuals nor Microsoft Gantt Chart).

What I’m trying to do is, if a particular task / activity has a start date (i.e. 30/07/2022) that is <= today(), then give me a 1, that is plotted on the matrix, which using the example should plot 1 next to the activity in 2022 July and 2022 August.

Similarly, if the activity has end_date that is > today() then give me a 2, that is plotted on the matrix, otherwise if the activity hasn’t started then give me a 0.

My current dax is as below:

 

VAR Start_date =

CALCULATE(

    MIN(Task_All[___START_DATE]),

    REMOVEFILTERS(FinishCalendar)

)

 

VAR End_Date =

CALCULATE(

    MAX(Task_All[___END_DATE]),

    REMOVEFILTERS(FinishCalendar)

)

 

VAR Min_date = MIN(FinishCalendar[Date])

 

VAR ProjectPeriod =

    Min_date >= Start_date

    && Min_date <= End_Date

 

VAR ProjectStatus =

CALCULATE(

    MIN(Task_All[___IsDelivered]),

    REMOVEFILTERS(FinishCalendar[Date])

)

RETURN

SWITCH(

    TRUE(),

    ProjectPeriod && FILTER(Task_All,Task_All[___START_DATE] <=TODAY()), 1,

     ProjectPeriod && FILTER(Task_All,Task_All[___END_DATE] > TODAY()), 2,

    0

)

 

Mido99_0-1664551329237.pngMido99_1-1664551355687.png

 

1 REPLY 1
lbendlin
Super User
Super User

Is that the full measure code?  What is ProjectStatus used for?

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.

Top Solution Authors