Forum Discussion

eliasayyy's avatar
eliasayyy
Icon for Memorable Member rankMemorable Member
11 months ago
Solved

Show Data from date range from 2 date tables with no relationships

hey everyone, im trying to build a dahsboard with a filter page like this start of week is from a dimdate table called Startdate end of week is from another dimdate table called end...
  • GrowthNatives's avatar
    11 months ago

    Hi eliasayyy , you can follow these steps to get your required solution 

    1. Keep only one active relationship: dimDate[Date] โ†’ Fact[DateKey].
      StartDate and EndDate tables must be disconnected (no relationships to anything). Use them only for slicers.

    2.  Axis/rows: fields from dimDate (e.g., dimDate[DayName], dimDate[Date]).
      Never put StartDate/EndDate columns on the visual.

    3. Replace your DAX 

    Measure in Selected Range :=
    VAR _start = MIN ( StartDate[Date] )
    VAR _end   = MAX ( EndDate[Date] )
    RETURN
    IF (
        NOT ISBLANK ( _start ) &&
        NOT ISBLANK ( _end ) &&
        _start <= _end,
        CALCULATE (
            [My Measure],                         -- e.g. SUM(Fact[value])
            KEEPFILTERS ( dimDate[Date] >= _start ),
            KEEPFILTERS ( dimDate[Date] <= _end )
        )
    )


    KEEPFILTERS preserves the visualโ€™s dimDate[DayName] context.
    Filtering the column (dimDate[Date] >= _start / <= _end) avoids the dependency on having dimDate[Date] in the visual.


    โญHope this solution helps you make the most of Power BI! If it did, click 'Mark as Solution' to help others find the right answers.
    ๐Ÿ’กFound it helpful? Show some love with kudos ๐Ÿ‘ as your support keeps our community thriving!
    ๐Ÿš€Letโ€™s keep building smarter, data-driven solutions together!๐Ÿš€  [Explore More]