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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors