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
Anmolgan
Post Prodigy
Post Prodigy

How to combine two DAX functions into one?

I have two dax functions that looks like this below:

 

Measure4 = CALCULATE(sum(f_Kronos[Minutes]) - "60", FILTER(f_Kronos, f_Kronos[Subtraction Column]= "Subtract 60"))
 
Measure 3 = CALCULATE(sum(f_Kronos[Minutes]) - "30", FILTER(f_Kronos, f_Kronos[Subtraction Column]= "Subtract 30"))
 
I want to combine them into single formula so that I can get the above two working as per single column in the table, is that possible?
1 ACCEPTED SOLUTION

@affan @edhans  I used below to solve my issue:

 

Working Hours = var a= IF('f_Kronos'[Subtraction Column]="Subtract 60" || 'f_Kronos'[Subtraction Column]="Subtract 30",'f_Kronos'[Minutes]-60,'f_Kronos'[Minutes]-30)

var b= a/60

return b

View solution in original post

8 REPLIES 8
edhans
Super User
Super User

Combine them how? Either/Or would be OR() or ||, And would be AND() or &&, or you could evalueate with an IF() statment to return one or the other.

If you want to add them, just put a + between them.

 

Otherwise, please explain your desired output.



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

@edhans I want to nest the calculated columns together with OR statment but do not know how to do that.

Is this what you want?

New Column =
OR(
    CALCULATE(
        SUM( f_Kronos[Minutes] ) - "60",
        FILTER(
            f_Kronos,
            f_Kronos[Subtraction Column] = "Subtract 60"
        )
    ),
    CALCULATE(
        SUM( f_Kronos[Minutes] ) - "30",
        FILTER(
            f_Kronos,
            f_Kronos[Subtraction Column] = "Subtract 30"
        )
    )
)

 Without seeing your data or what you are doing, hard to know. 



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

@edhans  This gives me True and False values only in place of the columns, I need to subtract 60 and 30 according to the conditional column that I have, in other terms, subtract 60 minutes from minutes column where minutes are more then or equal to 540, and subtract 30 from those where minutes are less then 540, I hope am able to explain you now.

Hi @Anmolgan 

 

Please try the below measure 

 

 

Measure 5 = 

var _30=CALCULATE(sum(f_Kronos[Minutes]) - "30", FILTER(f_Kronos, f_Kronos[Subtraction Column]= "Subtract 30"))
var _60=CALCULATE(sum(f_Kronos[Minutes]) - "60", FILTER(f_Kronos, f_Kronos[Subtraction Column]= "Subtract 60"))

Return  

IF(_30=-30,_30,_60)

 

 

 

Annotation 2020-04-17 020557.png

 

If this helped you, please mark this post as an accepted solution and like to give KUDOS .

 

Regards,

Affan Farooqi

@affan  It helped but its not subtracting the amounts from the hours measure.

@affan @edhans  I used below to solve my issue:

 

Working Hours = var a= IF('f_Kronos'[Subtraction Column]="Subtract 60" || 'f_Kronos'[Subtraction Column]="Subtract 30",'f_Kronos'[Minutes]-60,'f_Kronos'[Minutes]-30)

var b= a/60

return b

Below is the file where am trying to do this, check page 2 and measure 3 and measure 4

 

https://ifitech-my.sharepoint.com/:u:/g/personal/anmol_ganju_ifi_tech/EU7vG5uMJF5GiThNdPHPY5UBNfimkU...

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.