Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Calculate + IF in DAX for Power BI

I have a table (PIB) with 3 fields: Name, Filter and Value
I have this Measure to deploy Data, and it works:

 Data = CALCULATE(
                SUM('PIB'[Value]),    
                'PIB'[Filter] IN { "Dato base" }
                )

I want to add an IF (or something similar) to multiply Value by -1 when column Name equals to "Companies". I have tried this, and doesn`t work:

Data = CALCULATE(
                IF('PIB'[Name]=Companies; SUM('PIB'[Value])*-1;SUM('PIB'[Value])),    
                'PIB'[Filter] IN { " Dato base" }
                )

Anybody knows how can I do it? This way or any other
Thank you!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Data = 
VAR x = 
CALCULATE(
        SUM('PIB'[Value]),    
        'PIB'[Filter] IN { "Dato base" }
        )
RETURN 
IF(MAX(PIB[Name]) = "Companies", x*-1, x) 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading