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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
azaterol
Helper V
Helper V

Need DAX help

Hey,

 

I wrote SQL script but I want it also in Power BI.

The SQL is 

 

Select Distinct DocNr, Salary
FROM DocPosition
JOIN Document ON DocPosition.PosNr = Document.DocNr
WHERE DocDate Between '01.04.2022' and '30.04.2022' and DocPosition.Nr = 4300 and DocArt =3

 

My idea is:

Doc Salary= CALCULATE(DISTINCT(Document[DocNr]),SUM(Document[Salary]))
 
But it wont work.
 
You have an idea how I can transport it to DAX language?

 

 

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @azaterol 

Thanks for reaching out to us.

>> to  transport it to DAX language

vxiaotang_0-1659598765481.png

You can try this,

Table = 
var _t1= SELECTCOLUMNS(FILTER(Table_1,Table_1[Nr]=4300),"PosNr",[PosNr])
var _t2= SELECTCOLUMNS(FILTER(Table_2,Table_2[DocDate]<=DATE(2022,4,30) && Table_2[DocDate]>=DATE(2022,4,1) && Table_2[DocArt]=3 && Table_2[DocNr] in _t1),"DocNr",[DocNr],"Salary",[Salary])
return _t2

vxiaotang_1-1659599283256.png

 

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @azaterol 

Thanks for reaching out to us.

>> to  transport it to DAX language

vxiaotang_0-1659598765481.png

You can try this,

Table = 
var _t1= SELECTCOLUMNS(FILTER(Table_1,Table_1[Nr]=4300),"PosNr",[PosNr])
var _t2= SELECTCOLUMNS(FILTER(Table_2,Table_2[DocDate]<=DATE(2022,4,30) && Table_2[DocDate]>=DATE(2022,4,1) && Table_2[DocArt]=3 && Table_2[DocNr] in _t1),"DocNr",[DocNr],"Salary",[Salary])
return _t2

vxiaotang_1-1659599283256.png

 

 

Best Regards,

Community Support Team _Tang

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

amitchandak
Super User
Super User

@azaterol , In power bi You will take Document[DocNr] as unsummarized measure and you can use a measure

SUM(Document[Salary])

 

Filter can used using filter of slicer or you can use measure filter

 

example

 

calculate(SUM(Document[Salary]), filter(Document, DocDate >= date(2022,04,01) && DocDate < = date(2022,04,30) && [DocPosition.Nr] = 4300 && [DocArt] =3 ))

 

 

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.