cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Purushoth85
Advocate I
Advocate I

DAX Code Explanation

Hi Experts,

 

I couldnt able to understand what does this DAX code means?

 

daxcodemean.PNGAnyone, Please help.

 

Thank you

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Purushoth85 , if there is no value for sum, then give 0. It will create a left join with dimension

 

same as

sum('Financial Overview'[balance]) +0

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

AllisonKennedy
Super User
Super User

@Purushoth85 

 

A DAX Measure can't be fully defined until you provide the context - so to truly explain what it gives you need to know what table/visual you're using it in, but I'll do my best.

 

Let's break it into parts. We have

SUM('Financial Overview'[Balance])

in there twice, so I'm going to call that [TotalBalance]:

[TotalBalance]  = SUM('Financial Overview'[Balance])

 

The [TotalBalance] is just adding up the value from the Balance column in the Financial Overview table. If you put this in a Card visual, it gives the Grand Total Balance. If you put this in a visual by Year, Month, it will filter the Financial Overview table for that year and month, and then add up all the values in the Balance column for those dates. 

 

Looking at the rest of the measure, now that we have defined [TotalBalance], we can then rewrite the measure as: 

 

Sum of Balance = IF( [TotalBalance] = BLANK() , 0, [TotalBalance] )

 

Which hopefully makes it a little easier to see that if the [TotalBalance] is blank (in other words there was no row in the Financial Overview table for that Year and Month), then replace it with 0, otherwise give the [TotalBalance]. This forces ALL months and years to be shown in the table visual, even if there was no balance record in the Financial Overview table on that month/year.

 

Does that help?

 

You could simplify this a bit by writing: 

Sum of Balance = 0 + SUM('Financial Overview'[Balance])

 

and you'll still get the same result.

 


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

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

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

View solution in original post

2 REPLIES 2
AllisonKennedy
Super User
Super User

@Purushoth85 

 

A DAX Measure can't be fully defined until you provide the context - so to truly explain what it gives you need to know what table/visual you're using it in, but I'll do my best.

 

Let's break it into parts. We have

SUM('Financial Overview'[Balance])

in there twice, so I'm going to call that [TotalBalance]:

[TotalBalance]  = SUM('Financial Overview'[Balance])

 

The [TotalBalance] is just adding up the value from the Balance column in the Financial Overview table. If you put this in a Card visual, it gives the Grand Total Balance. If you put this in a visual by Year, Month, it will filter the Financial Overview table for that year and month, and then add up all the values in the Balance column for those dates. 

 

Looking at the rest of the measure, now that we have defined [TotalBalance], we can then rewrite the measure as: 

 

Sum of Balance = IF( [TotalBalance] = BLANK() , 0, [TotalBalance] )

 

Which hopefully makes it a little easier to see that if the [TotalBalance] is blank (in other words there was no row in the Financial Overview table for that Year and Month), then replace it with 0, otherwise give the [TotalBalance]. This forces ALL months and years to be shown in the table visual, even if there was no balance record in the Financial Overview table on that month/year.

 

Does that help?

 

You could simplify this a bit by writing: 

Sum of Balance = 0 + SUM('Financial Overview'[Balance])

 

and you'll still get the same result.

 


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

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

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

View solution in original post

amitchandak
Super User
Super User

@Purushoth85 , if there is no value for sum, then give 0. It will create a left join with dimension

 

same as

sum('Financial Overview'[balance]) +0

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.