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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Luukvv93
Helper II
Helper II

Need help with a measure: iterating through times

Hi all,

 

I have one fact table (first image) and a dimension time including duration per shift (dag=day and avond=evening).

For each line in the fact table (first image) I want a calculated column that calculates whether the shift is day or evening (based on the shifts in the second image).

 

All help is greatly appreciated

 

 

 

tempsnip.png

 tempsnip.png

 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

@Luukvv93

Sorry, it's missing the VALUES( )

 

WhatShift =
CALCULATE (
    VALUES(DimDate[Shift]),
    FILTER (
        DimDate,
        DimDate[Datum] = FactTable[DatumTijd].[Date]
            && FactTable[DatumTijd] >= DimDate[StartTijd]
            && (
                FactTable[DatumTijd] <= DimDate[EindTijd]
                    || DimDate[EindTijd] = BLANK ()
            )
    )
)

View solution in original post

6 REPLIES 6
AlB
Community Champion
Community Champion

@Luukvv93

Try this for your calculated column:

 

WhatShift =
CALCULATE (
    DimDate[Shift],
    FILTER (
        DimDate,
        DimDate[Datum] = FactTable[DatumTijd].[Date]
            && FactTable[DatumTijd] >= DimDate[StartTijd]
            && (
                FactTable[DatumTijd] <= DimDate[EindTijd]
                    || DimDate[EindTijd] = BLANK ()
            )
    )
)

 

I see that there's a blank for one of the [EindTijd] values. The code assumes that's equivalent to the end of the day.   

Hi @AlB,

 

After calculate it's impossible to put DimDate[Shift], any idea how to resolve? Proper connections have been made in the data model so that's not hte issue

AlB
Community Champion
Community Champion

@Luukvv93

Sorry, it's missing the VALUES( )

 

WhatShift =
CALCULATE (
    VALUES(DimDate[Shift]),
    FILTER (
        DimDate,
        DimDate[Datum] = FactTable[DatumTijd].[Date]
            && FactTable[DatumTijd] >= DimDate[StartTijd]
            && (
                FactTable[DatumTijd] <= DimDate[EindTijd]
                    || DimDate[EindTijd] = BLANK ()
            )
    )
)

@AlB Will figure it out tomorrow, thanks for the help

AlB
Community Champion
Community Champion

Hi @Luukvv93

 

You mean you want to take the Date/Time value in your first table in column 'DatumTijd' and check where that value falls in the second table, i.e.  between what StartTijd and EindTijd and from there determine whether it is Avond or Dag?

@AlB, That's correct!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors