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
Anonymous
Not applicable

Calculating Totals with filter but considering initial range

Hello,

I am seeking for help as i've been trying a couple days to solve this DAX calculation and I just can't figure it out.

 

I have a Table with orders, categories (SAL_TEMP) unit prices and number of units.

I have created a calculated column with ranges of prices.

Now, i want to calculate the aggregate of each order without considering the dimension"SAL_TEMP" and the calculated colum "BKT Price" but only from the "Contracts" appearing in first instance.

 

The result should be like this:

armandpr_0-1642416442664.png

The Table1 down below shows how many orders have each category. I'm interested in the "Total" as i want to know for each "BKT Price"  how many units there are but only from the "Contracts" appearing on every row.

The Table2 shows how many units have each order.

armandpr_1-1642416494453.png

If i do something like:

Calculated11 :=
CALCULATE(
SUM('ONLINE PowerBi'[Units]),
ALL('ONLINE PowerBi'[SAL_TEMP],'ONLINE PowerBi'[BKT Price])
)
The returned result is (as expected):
armandpr_2-1642417366501.png

 

I can't attach the Pbix, but there's the table:

OrderSAL_TEMPBKT PricePriceUnitsFamily
90002842271SALDO2 - 2.992,431185
90002842271SALDO3 - 3.993,241173
90002842271SALDO3 - 3.993,241177
90002842271TEMPORADA4 - 4.994,871316
90002856331SALDO4 - 4.994,121676
90002856331TEMPORADA4 - 4.994,951942
90002842271TEMPORADA5 - 5.995,681268
90002842271SALDO6 - 9.996,51188
90002842271TEMPORADA6 - 9.998,121133

 

If someone can give me a hand I would be incredibly grateful. 

 

Best regards,

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Solved! 💪 I was basically not being aware of the filter context. 

Just in case someone is in my pants, the solution is:

bis =
IF( ISINSCOPE('ONLINE PowerBi'[BKT Price]) ,
(CALCULATE(
(CALCULATE (
SUM ( 'ONLINE PowerBi'[Units]),
VALUES ( 'ONLINE PowerBi'[Order]),ALL('ONLINE PowerBi'[BKT Price],'ONLINE PowerBi'[SAL_TEMP])
)),
ALL('ONLINE PowerBi'[SAL_TEMP])
)),
BLANK()
)

 

And this returns: 

 

 

armandpr_0-1642427328121.png

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Solved! 💪 I was basically not being aware of the filter context. 

Just in case someone is in my pants, the solution is:

bis =
IF( ISINSCOPE('ONLINE PowerBi'[BKT Price]) ,
(CALCULATE(
(CALCULATE (
SUM ( 'ONLINE PowerBi'[Units]),
VALUES ( 'ONLINE PowerBi'[Order]),ALL('ONLINE PowerBi'[BKT Price],'ONLINE PowerBi'[SAL_TEMP])
)),
ALL('ONLINE PowerBi'[SAL_TEMP])
)),
BLANK()
)

 

And this returns: 

 

 

armandpr_0-1642427328121.png

 

Anonymous
Not applicable

So far, i have accomplished this. Still not being correct though... @amitchandak thank you!

armandpr_0-1642421748641.png

FINAL =
VAR var1=
CALCULATE (
SUM ( 'ONLINE PowerBi'[Units]),
VALUES ( 'ONLINE PowerBi'[Order]),ALL('ONLINE PowerBi'[BKT Price],'ONLINE PowerBi'[SAL_TEMP])
)
RETURN
IF( ISINSCOPE('ONLINE PowerBi'[BKT Price]) , var1, BLANK())
amitchandak
Super User
Super User

@Anonymous , I case you need value only at few place

then use isinscope

if( isinscope(Table[BKT Prive])  , [calculated 11], blank())

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