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
perezco
Advocate III
Advocate III

using treatas to filter data

Order#Qty_itemstreatas_distinct_commoditytotal_orders_with_1_Commodity
666289448611
666610474111
666076242511
66682382465 
66682210454 
66667869376 
666322541108 
66673054732 
66569990122 
66684804022 
66621212654 
66403793642 

 

 

The above table is compose virtual connection of  fact dispatch item ordered with commodity part label by using treatas to allow me use te commodity_name

 

looking to get without showing the order#

Qty_itemstreatas_distinct_commoditytotal_orders_with_1_Commodity
611
111
511

12 (total                                                                                   3(total order)

qty items)   

 

------------------------------------------------------------

formulas that I been trying:

  1. MEASURES

    _Total Dispatches with 1 Commodity Qty2 =

    VAR T1 =

    SUMMARIZE(

    'Fact - DIO',

    -- Group by ---

    ''Fact - DIO'[Order_ID],

    -- Count distinct Commodity per Dispatch

    "DistCount", DISTINCTCOUNT ('Fact - DIO'[Commodity Description2] )

    )

    VAR ItemOrderedQty = SUM('Fact - DIO'[ITM_QTY])

     

    return

    sumx(

    filter(

    T1,

    [DistCount] = 1

    ),

    ItemOrderedQty

    );

    TreatAS_Distinct_Commodity =

    CALCULATE(

                DISTINCTCOUNT('Hier - Commodity'[COMDTY_NM])

                , TREATAS (

    CALCULATETABLE(VALUES ( 'Fact - DIO'[ITM_NBR] )),

    'Hier - Commodity'[PART_NBR]

    )

            );

    _Total Dispatches with 1 Commodity =

    COUNTROWS (

    FILTER (

    SUMMARIZE (

    'Fact - DIO',

    'Fact - DIO'[SVC_DSPCH_ID],

    -- Count distinct Commodity per Dispatch

    "DistCount", DISTINCTCOUNT ('Fact - DIO'[Commodity Description2] )

    ),

    [DistCount] = 1

    )

    )

  2. COLUMN   ////(column create in the 'Fact - DIO')

    Commodity Description2
    = CALCULATETABLE (

    VALUES ( 'Hier - Commodity'[COMDTY_NM] ),

    TREATAS (

    CALCULATETABLE ( VALUES ( 'Fact - DIO'[ITM_NBR] ) ),

    'Hier - Commodity'[PART_NBR]

    )

    )

 

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @perezco 

I can't reproduce your problem.

Please show me more details like simple example data, relationships of tables.

 

In addition, please refer to 

How to use the TREATAS function in DAX

 

Best Regards
Maggie

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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