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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Calculate and IF

Hello,

 

well maybe its impossible but... but here my idea:

 

I have 2 Tables

  • model with layerID
  • datasocurce with layerID and costs

 

layerID are divided i 2 types

  • normal
  • aggregation (usualy sum of normal or other aggregations)

what i´m looking for

  • have 1 table and have in 1 column the results (costs by layers, normal and aggreation)
  • ... well i know how to make this work in many many tables, but this isnt my task

well my idea is

=
IF layerID = 100 then calculate () // first aggreation 

IF layerID = 200 then calculate () // second aggreation 

...

ELSE calculate(sum(datasource[costs]), model[layerID])

 

can it work?

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , a measure like

if(max(layerID) = 100, calculate (),calculate ())

or

sumx(summarize(table,table[layerID],"_1",if(max(layerID) = 100, calculate (),calculate ()) ),[_1])

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

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , a measure like

if(max(layerID) = 100, calculate (),calculate ())

or

sumx(summarize(table,table[layerID],"_1",if(max(layerID) = 100, calculate (),calculate ()) ),[_1])

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

@amitchandak 
first ofall thank You, but if i try...

 

Measure =
if(max(_Modell[VerdichtungsId])=100,
CALCULATE(1+1+1)
, CALCULATE(SUM(FactPlan[Saldo-Plan]),FactPlan[VerdichtungsId]))
 
then i get back 3 - korrekt, but if i try
 
Measure =
if(max(_Modell[VerdichtungsId])=100,
CALCULATE(SUM(FactPlan[Saldo-Plan]),FactPlan[VerdichtungsId]=101)
, CALCULATE(SUM(FactPlan[Saldo-Plan]),FactPlan[VerdichtungsId]))
 
then i get back EMPTY ("")...
 
btw. Results in ELSE are korrekt
 
What is my mistake?
 
Anonymous
Not applicable

😄

 

found my error: "..., Filter(Allselected(Table), Table(ID)=IdNr)..."

 

ty

harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Try using RELATED function.

 

https://docs.microsoft.com/en-us/dax/related-function-dax

 

and the the SWITCH function

 

https://dax.guide/switch/

 

Also,

share sample data of your tables and expected output to help you better.

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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