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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PietroFarias
Resolver II
Resolver II

Help with DAX Code

I need help with the DAX below:

 

 

EVALUATE
CALCULATETABLE (
    SUMMARIZE (
        fVendas,
        dadosFILIAL[ID],
        fVendas[NF],
        "PRODUCT 1", CALCULATE (
            [Volume do Periodo],
            FILTER ( dProdutos, dProdutos[typeProduct] = "PRODUCT 1" )
        ),
        "PRODUCT 2", CALCULATE (
            [Volume do Periodo],
            FILTER ( ALL ( dProdutos ), dProdutos[typeProduct] = "PRODUCT 2" )
        )
    ),
    FILTER ( dProdutos, dProdutos[BRAND] = "BRAND X" )
)

 

 

 

I applied a FILTER together with the CALCULATE TABLE of the Products table (dProducts), returning only the products of the brand 'brand x'.
 
In Column 'PRODUCT 1' contains the sum of the volume sold of 'PRODUCT 1'. There are 'PRODUCT 1' within the products table where you have the 'brand x'. OK
 
The problem is:
The 'PRODUCT 2' will NEVER have an 'brand x'. Thinking about it, I used an ALL (dProdutos) to not suffer the filter. But, the calculation keeps returning empty.
 
What am I doing wrong?

 

1 ACCEPTED SOLUTION
PietroFarias
Resolver II
Resolver II

Thanks for all.

 

I read 1000x and change the DAX and it worked.

 

EVALUATE
CALCULATETABLE (
ADDCOLUMNS(
    SUMMARIZE (
        fVendas,
        dadosFILIAL[ID],
        fVendas[NF],
        "PRODUCT 1", CALCULATE (
            [Volume do Periodo],
            FILTER ( dProdutos, dProdutos[typeProduct] = "PRODUCT 1" )
        )
    ),"PRODUCT 2", 
        CALCULATE (
            [Volume do Periodo],
            FILTER ( ALL ( dProdutos ), dProdutos[typeProduct] = "PRODUCT 2" )
        )
),
    FILTER ( dProdutos, dProdutos[BRAND] = "BRAND X" )
)

 

 

As I understand it, when taking it out of the SUMMARIZE, he can apply ALL (dProduct). And within the SUMMARIZE he already received the FILTER from CALCULATETABLE before performing ALL. I don't know if I'm talking nonsense.

View solution in original post

4 REPLIES 4
PietroFarias
Resolver II
Resolver II

Thanks for all.

 

I read 1000x and change the DAX and it worked.

 

EVALUATE
CALCULATETABLE (
ADDCOLUMNS(
    SUMMARIZE (
        fVendas,
        dadosFILIAL[ID],
        fVendas[NF],
        "PRODUCT 1", CALCULATE (
            [Volume do Periodo],
            FILTER ( dProdutos, dProdutos[typeProduct] = "PRODUCT 1" )
        )
    ),"PRODUCT 2", 
        CALCULATE (
            [Volume do Periodo],
            FILTER ( ALL ( dProdutos ), dProdutos[typeProduct] = "PRODUCT 2" )
        )
),
    FILTER ( dProdutos, dProdutos[BRAND] = "BRAND X" )
)

 

 

As I understand it, when taking it out of the SUMMARIZE, he can apply ALL (dProduct). And within the SUMMARIZE he already received the FILTER from CALCULATETABLE before performing ALL. I don't know if I'm talking nonsense.

edhans
Super User
Super User

Your Summarize is returning a table.

Then your Calculate Table is taking that table and filtering out products without brand X, and that filter is propigating to the SUMMARIZE table.

 

to see this, get rid of the CALCULATETABLE and FILTER function, Just look at what your SUMMARIZE is doing first. If that is ok, then you'll need to do something else in the FILTER.

For any further assistance, you'll need to link to a PBIX file in ONeDrive or Dropbox or similar. Don't put tables in a post. Your model needs to be examined. Remove any confidientail info or create a model with fake data.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
amitchandak
Super User
Super User

@PietroFarias ,

I think the filter on the top table is removing it. The only measure which can get filter is Product 1, move filter there

SUMMARIZE (
        fVendas,
        dadosFILIAL[ID],
        fVendas[NF],
        "PRODUCT 1", CALCULATE (
            [Volume do Periodo],
            FILTER ( dProdutos, dProdutos[typeProduct] = "PRODUCT 1" && dProdutos[BRAND] = "BRAND X")
        ),
        "PRODUCT 2", CALCULATE (
            [Volume do Periodo],
            FILTER ( ALL ( dProdutos ), dProdutos[typeProduct] = "PRODUCT 2" )
        )
    )

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Ashish_Mathur
Super User
Super User

Hi,

Share some data, explain the business context and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.