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
Jensej
Helper V
Helper V

SQL to Dax, Multiple Wheres

Hey There

 

So i have this two SQL Select. I want to make a measure with the Total off Select1 - Select2 but cant get it to work. Have tried with CALCULATE,SUM,Switch and Filter functions but im to new to power bi to get it to work. Woule appreicate if someone could help me.

 

SELECT SUM(BetragSw) FROM bi_Budget

WHERE Konto_KontoNrFIB IN ('344100') and Buchungen_KontoNrFIB = '344100'

 

-

SELECT SUM(BetragSw) FROM bi_Budget

WHERE Konto_KontoNrFIB IN ('344100') and GegKontoNr = '344100'

 

2 REPLIES 2
negi007
Community Champion
Community Champion

You can use variable in your dax syntex. First variable to store value from first condition and second variable to store value from second condition. Then you can sum easily value of first and second variable to calculate sum of two conditions. 

your syntex could be like below:- 

Total :=
VAR
Buchungen = CALCULATE (SUM ( Sales[BetragSw] ), Buchungen_KontoNrFIB = '344100' ))
VAR
GegKontoNr = CALCULATE (SUM ( Sales[BetragSw] ), GegKontoNr = '344100' ))
RETURN
(Buchungen + GegKontoNr)




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

amitchandak
Super User
Super User

@Jensej , try like

calculate(sum(bi_Budget[BetragSw]),bi_Budget[Konto_KontoNrFIB] IN {"344100"},bi_Budget[Buchungen_KontoNrFIB] = "344100")

 

calculate(sum(bi_Budget[BetragSw]),bi_Budget[Konto_KontoNrFIB] IN {"344100"},bi_Budget[GegKontoNr] = "344100")

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.