cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
martin93
Frequent Visitor

Is it possible to transform such Oracle SQL function into DAX

hello,

 

I am trying to transform the following Oracle SQL function into DAX but without any success. Could you please help me how to solve it? The functionality of this field should be like that you input account value into ${account} and then it shows you relevant result.

 

SELECT

sum(CASE
WHEN "accountMD" = ${account} THEN -1*"amount"
ELSE "amount"
END
) OVER (PARTITION BY "businessPartnerNumber") AS SUM

FROM Table

 

Thank you,

Martin

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @martin93 ,

I created some data:

Table:

vyangliumsft_0-1656037069405.png

Table2:

vyangliumsft_1-1656037069405.png

Here are the steps you can follow:

1. Use [account] of Table2 as a slicer.

vyangliumsft_2-1656037069408.png

2. Create measure.

if_Measure =
var _select=SELECTEDVALUE('Table 2'[account])
return
IF(
    MAX('Table'[accountMD])=_select,-1*MAX('Table'[amount]),MAX('Table'[amount]))
SUM =
SUMX(FILTER(ALL('Table'),'Table'[businessPartnerNumber]=MAX('Table'[businessPartnerNumber])),[if_Measure])

3. Result:

vyangliumsft_3-1656037069410.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @martin93 ,

I created some data:

Table:

vyangliumsft_0-1656037069405.png

Table2:

vyangliumsft_1-1656037069405.png

Here are the steps you can follow:

1. Use [account] of Table2 as a slicer.

vyangliumsft_2-1656037069408.png

2. Create measure.

if_Measure =
var _select=SELECTEDVALUE('Table 2'[account])
return
IF(
    MAX('Table'[accountMD])=_select,-1*MAX('Table'[amount]),MAX('Table'[amount]))
SUM =
SUMX(FILTER(ALL('Table'),'Table'[businessPartnerNumber]=MAX('Table'[businessPartnerNumber])),[if_Measure])

3. Result:

vyangliumsft_3-1656037069410.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors