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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Amit92
Regular Visitor

Using Treatas without Filtering the Dataset

Hi Everyone, 

Hope you are doing good.

I have 2 sample datasets as below:

Amit92_0-1747839426388.png

 

I have created a measure named 

Amt_Total_Treatas  = 
CALCULATE(SUM(Amt[Amt]), TREATAS(VALUES('Group'[Cust]), Amt[Cust]))

I created this measure because i need to filter the Amt[Amt] from the Group table without creating relationship.
But when i checked the value of this measure, it only shows the amount for customers present in the Group table, (not those custs which absent in the Group table but present in the Amt table ):

Amit92_1-1747839707621.png

I want this measure to show the total value as 2968, not 1491 (perhaps showing the remaining amounts as blank). Can you help me with this?

 

(This is a sample dataset i created, in my original dataset i need to achieve the same thing without creating relationship)

Here are the data in each table if you need for example:

Amt
Amit92_2-1747840191243.png

 

Group

 

Amit92_3-1747840214101.png

 



 
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

I think the below should work. It will give the value for the current group if the group is in scope, otherwise it will give the total

Amt Total Treatas =
VAR AllAmtNames =
    DISTINCT ( Amt[Cust] )
VAR AllGroupNames =
    DISTINCT ( ALL ( Group[Cust] ) )
VAR MissingAmtNames =
    EXCEPT ( AllAmtNames, AllGroupNames )
VAR Result =
    IF (
        ISINSCOPE ( Group[Cust] ),
        CALCULATE ( SUM ( Amt[Amount] ), TREATAS ( VALUES ( Group[Cust] ), Amt[Cust] ) ),
        CALCULATE (
            SUM ( Amt[Amount] ),
            TREATAS ( UNION ( VALUES ( Group[Cust] ), MissingAmtNames ), Amt[Cust] )
        )
    )
RETURN
    Result

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

I think the below should work. It will give the value for the current group if the group is in scope, otherwise it will give the total

Amt Total Treatas =
VAR AllAmtNames =
    DISTINCT ( Amt[Cust] )
VAR AllGroupNames =
    DISTINCT ( ALL ( Group[Cust] ) )
VAR MissingAmtNames =
    EXCEPT ( AllAmtNames, AllGroupNames )
VAR Result =
    IF (
        ISINSCOPE ( Group[Cust] ),
        CALCULATE ( SUM ( Amt[Amount] ), TREATAS ( VALUES ( Group[Cust] ), Amt[Cust] ) ),
        CALCULATE (
            SUM ( Amt[Amount] ),
            TREATAS ( UNION ( VALUES ( Group[Cust] ), MissingAmtNames ), Amt[Cust] )
        )
    )
RETURN
    Result

Thanks @johnt75 
You saved me 🙂 

johnt75
Super User
Super User

You can try

Amt_Total_Treatas =
CALCULATE (
    SUM ( Amt[Amt] ),
    TREATAS ( UNION ( VALUES ( 'Group'[Cust] ), { BLANK () } ), Amt[Cust] )
)

Hi John,

Thanks for the comment, 🙂

However i am getting the same result for this as my previous measure, check below:

Amit92_0-1747843386315.png

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors