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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
v-yiruan-msft
Community Support
Community Support

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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