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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
kmansweden
Frequent Visitor

Filter table with variale table as argument

Hi,

 

I am trying to filter one factTable with a variable table of another filtered factTable.
Problem is IN VALUES doesnt accept a vTable. 
I have tried INTERSECT but not really sure how to complete it with that.


The goal is to SUM up all timestampes in

FactWorkShopStampings[StampedTime]

where 

FactWorkShopStampings[OrderNumber] 

has a match in 
FactUnInvoicedWorkShopOrderRow[OrderNumber]


This is what I tried

WeekRpt - UnInvoiced - Stamped Time_Single = 

VAR _LastTransferDate = MAX( FactUnInvoicedWorkShopOrderRow[EventDate] )

VAR __TempTable = 
    CALCULATETABLE(
        SELECTCOLUMNS( FactUnInvoicedWorkShopOrderRow,
            "COSTCENTER", LOOKUPVALUE( CostCenter[CosterCenterIDShort], CostCenter[Department_KEY], FactUnInvoicedWorkShopOrderRow[Department_KEY] ),
            "ORDERNUMBER", FactUnInvoicedWorkShopOrderRow[OrderNumber],
            "EVENTDATE", FactUnInvoicedWorkShopOrderRow[EventDate]
        ),
        FILTER(  
            FactUnInvoicedWorkShopOrderRow ,
                FactUnInvoicedWorkShopOrderRow[EventDate] = _LastTransferDate
        )
    )
 VAR __TempTableGroupBy =
    GROUPBY (
        __TempTable,
        [COSTCENTER],
        [ORDERNUMBER],
        [EVENTDATE]

    )
 VAR _SumStapedTime = 
    CALCULATE (
        SUM( FactWorkShopStampings[StampedTime] ),

        FILTER ( ALL( FactWorkShopStampings ) ,

            FactWorkShopStampings[OrderNumber] IN VALUES( __TempTableGroupBy[ORDERNUMBER] )

        )
    )

RETURN
    _SumStapedTime
1 REPLY 1
Anonymous
Not applicable

Hi @kmansweden ,

You can update the formula of measure [WeekRpt - UnInvoiced - Stamped Time_Single] as below and check if it can return the expected result...

WeekRpt - UnInvoiced - Stamped Time_Single =
VAR _LastTransferDate =
    MAX ( FactUnInvoicedWorkShopOrderRow[EventDate] )
VAR __TempTable =
    CALCULATETABLE (
        VALUES ( FactUnInvoicedWorkShopOrderRow[OrderNumber] ),
        FILTER (
            FactUnInvoicedWorkShopOrderRow,
            FactUnInvoicedWorkShopOrderRow[EventDate] = _LastTransferDate
        )
    )
VAR _SumStapedTime =
    CALCULATE (
        SUM ( FactWorkShopStampings[StampedTime] ),
        FILTER (
            ALL ( FactWorkShopStampings ),
            FactWorkShopStampings[OrderNumber] IN __TempTable
        )
    )
RETURN
    _SumStapedTime

Best Regards

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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