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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
OKgo
Advocate II
Advocate II

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

8 REPLIES 8
OKgo
Advocate II
Advocate II

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!:
The Definitive Guide to Power Query (M)

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!:
The Definitive Guide to Power Query (M)

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!:
The Definitive Guide to Power Query (M)

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.