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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
SHAKEDALROY
Helper I
Helper I

Creating a Measure

Hi,

 

I made a calculationg in SQL.. and i need to convert it to a measure in Power BI.

In my SQL i have 3 tables (FactParkingViolation,DimIssuer,DimIssuingAgency), when i added the the tables to Power BI i made a megre between the two tables - DimIssuer & DimIssuingAgency. so now I have two tables in Power BI -FactParkingViolation and DimIssuer. 

I'm not so familiar with Dax that's way i don't know how to create this measure.

Help will be much appriciated!

 

This is the SQL Query:

 

 SELECT SUM(IssuingAgencyAverageYearlySalary)*0.03

 FROM(

 SELECT DISTINCT(DI.IssuerID) ,IssuingAgencyAverageYearlySalary

  FROM FactParkingViolation FPV LEFT JOIN

 DimIssuer DI ON FPV.IssuerKey = DI.IssuerKey

 LEFT JOIN DimIssuingAgency DIA

 ON DI.IssuingAgencyCode = DIA.IssuingAgencyCode

 WHERE YEAR(IssueDate) = 2016 ) R

8 REPLIES 8
Anonymous
Not applicable

Hi @SHAKEDALROY ,

Could you tell me if your problem has been solved?
If it is, kindly Accept it as the solution. More people will benefit from it.
Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.


Best Regards,
Stephen Tao

Anonymous
Not applicable

Hi @SHAKEDALROY ,

 

You could leran the merge from this link.

 

After you merged, try this measure.

 

CALCULATE(SUM('Table'[IssuingAgencyAverageYearlySalary]),FILTER('TABLE',YEAR([IssueDate]) = 2016))*0.03

 

Best Regards,

Stephen Tao

 

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

AllisonKennedy
Community Champion
Community Champion

@SHAKEDALROY  the DAX For this is simple: 

 

Salary Measure = SUM(FactParkingViolation[IssuingAgencyAverageYearlySalary])*0.03

 

Or if you want it always for the year 2016:

UPDATED SYNTAX: 

Salary 2016 = SUMX(FILTER(FactParkingViolation, RELATED(Table[IssueDate]) = 2016), [IssuingAgencyAverageYearlySalary])*0.03)

 

The trick is creating the relationships. You don't need to do the Merge if you don't want to, but you do need to create relationships on FPV.IssuerKey = DI.IssuerKey and  DI.IssuingAgencyCode = DIA.IssuingAgencyCode

 

https://excelwithallison.blogspot.com/search?q=relationships

 

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi @AllisonKennedy  thank you for your reponse,

 

i needed to make that merge for different calculations.. i tried to add 'related' to the DAX formula you wrote to me but it still doesn't work, do you know way?

thank you.

image.png

@SHAKEDALROY  It looks like you have an extra ) before the comma. Sorry, that was my fault as it was in my formula too. That's what I get for writing DAX blindly!


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

i think something is still missing @AllisonKennedy /:

The result in SQL is 18,639,996

and when i tried your formula in Power BI the result is 451,796,281

How have you done the merge? Did you remove duplicates, your SQL code uses DISTINCT, which we haven't accounted for in the DAX. Also, it's possible to increase rows in merge if you're not careful. https://excelwithallison.blogspot.com/2020/10/merge-ahead-one-for-one.html 

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

amitchandak
Super User
Super User

@SHAKEDALROY , You have create 1 - Many retion between dimesions and fact

DimIssuingAgency - FactParkingViolation, DimIssuer -FactParkingViolation , Also join FactParkingViolation with date table having year on IssueDate (Date[Date])

 

Then You can add +0 in the measure you are creating to have left join

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.