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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
OKgo
Helper IV
Helper IV

Gantt Chart with Matrix Visual

Saw this cool post and decided to try it out
https://www.linkedin.com/posts/basdohmen_powerbi-design-activity-7172551962473795584-fPP_?utm_source...

 

I got very close with this 

Gantt = 
VAR StartDate = 
    CALCULATE(
        MIN(Batches[ManufacturingDate]),
        REMOVEFILTERS('Calendar'[Date])
    )
VAR EndDate = 
    CALCULATE(
        MIN(Batches[LabelledExpiry]),
        REMOVEFILTERS('Calendar'[Date])
    )
VAR ProjectPeriod = 
    AND(
        MIN('Calendar'[Date]) >= StartDate,
        MIN('Calendar'[Date]) <= EndDate
    )
VAR ProjectStatus = 
    CALCULATE(
        MIN(Batches[Status]),
        REMOVEFILTERS('Calendar'[Date])
    )
VAR Result = 
    IF(
        NOT(ProjectPeriod),
        BLANK(),
        SWITCH(
            TRUE(),
            ProjectStatus = "Manufactured", 1,
            ProjectStatus = "Plan", 2,
            ProjectStatus = "Cancelled", 3
        )
    )
RETURN
    Result

 

2024-03-10 15_42_36-Enterin Example.png

 

Can anyone see anything in the dax to make the numbers repeat every day unitl the expiry date? 


Thank you so much!

1 ACCEPTED SOLUTION

@OKgo OK, this worked for me. PBIX is attached below signature:

Gantt = 

VAR StartDate = 
    CALCULATE(
        MIN(Batches[Manufacturing Date]),
        ALLEXCEPT('Batches','Batches'[Status])
    )

VAR EndDate =
    CALCULATE(
        MIN(Batches[Labelled Expiry]),
        ALLEXCEPT('Batches','Batches'[Status])
    )

VAR CalendarStart = MIN('Calendar'[Date])

VAR CalendarEnd = MAX('Calendar'[Date])

VAR ProjectPeriod = IF( CalendarStart >= StartDate && CalendarEnd <= EndDate, 1, 0 )

VAR ProjectStatus = 
    CALCULATE(
        MIN(Batches[Status]),
        ALLEXCEPT('Batches','Batches'[Status])
    )

VAR Result = 
    IF(
        ProjectPeriod = 0, BLANK(),
        SWITCH(
            TRUE(),
            ProjectStatus = "Manufactured", 1,
            ProjectStatus = "Plan", 2,
            ProjectStatus = "Cancelled", 3
        )
    )
RETURN
    Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

8 REPLIES 8
OKgo
Helper IV
Helper IV

There is an active many to 1 relationship between Batches[ManufacturedDate) and Calendar[Date]. There is an inactive many to 1 relationship between Batches[LabelledExpiry] and Calendar[Date]

@OKgo Can you post sample data or sample file? Need to understand where things are coming from in your visual.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I hope this meets the ask:

 

It is coming from a SharePoint list the manufacturing date and labelled expiry date are the start and end of a the gantt bar. The row context is batch ID and status. The columns from the calendar table. And the mesure is of course in the value

 

Batch IDProductStatusManufacturing DateLabelled ExpiryManufactured Quantity
111ExpensivePlan3/8/20233/8/20241,122
222CheapManufactured3/17/20233/17/20255,000

@OKgo OK, so are you saying that Plan should go from 3/8/2023 to 3/8/2024 and manufacturing from 3/17/2023 to 3/17/2025 correct?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

yes thats it

@OKgo OK, this worked for me. PBIX is attached below signature:

Gantt = 

VAR StartDate = 
    CALCULATE(
        MIN(Batches[Manufacturing Date]),
        ALLEXCEPT('Batches','Batches'[Status])
    )

VAR EndDate =
    CALCULATE(
        MIN(Batches[Labelled Expiry]),
        ALLEXCEPT('Batches','Batches'[Status])
    )

VAR CalendarStart = MIN('Calendar'[Date])

VAR CalendarEnd = MAX('Calendar'[Date])

VAR ProjectPeriod = IF( CalendarStart >= StartDate && CalendarEnd <= EndDate, 1, 0 )

VAR ProjectStatus = 
    CALCULATE(
        MIN(Batches[Status]),
        ALLEXCEPT('Batches','Batches'[Status])
    )

VAR Result = 
    IF(
        ProjectPeriod = 0, BLANK(),
        SWITCH(
            TRUE(),
            ProjectStatus = "Manufactured", 1,
            ProjectStatus = "Plan", 2,
            ProjectStatus = "Cancelled", 3
        )
    )
RETURN
    Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Firstly fantastic filename!

 

The issue was the cross filter direction. You had set this to single and it worked when I applied the same logic to my model it worked. Thank you so much. This is for sure something I will read up more on. 

@OKgo Lol! Yeah, that was definitely not a typo! Glad you got it figured out!



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.