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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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