Skip to content
Home ยป DIVIDE Function DAX

DIVIDE Function DAX

DAX DIVIDE Function





DIVIDE function is a power bi DAX math and trig functions that performs the division and returns alternate result or BLANK() on division by 0.

It returns a decimal number.

SYNTAX

DIVIDE(<numerator>, <denominator> [,<alternateresult>])

numeratorย  The dividend or number to divide.

denominatorย  The divisor or number to divide by.

alternateresultย  It is an optional, returned when division by zero error occurred.

By default it returns blank().

Lets look at an example of using DIVIDE function in Power Bi.

Here we have a sample dataset of student score card.

Note that, You can see MaxMarks is 0 for studid 101 , and 104 in Subject English and Math respectively.

Which are taken purposely to see the DIVIDE function ability to handle the divide by zero error, and return alternate value if it is given else blank.

StudIdย  ย  ย  ย  ย  ย Subjectย  ย  ย  ย  ย  ย  ย  ย Marks Obtainย  ย MaxMarks

101 Math 79 100
101 Science 80 100
101 English 92 0
102 Math 83 100
102 Science 74 100
102 English 56 100
103 Math 69 100
103 Science 49 100
103 English 94 100
104 Math 75 0
104 Science 87 100
104 English 91 100

 

Lets say, you want to calculate the percentage achieved by student in each subject.

To calculate the percentage, first you need to divide Marks obtain (dividend) in subject by max marks (divisor) then multiple by the result by 100.

Lets use the DIVIDE function DAX for the division as given below.

Subject % =

DIVIDE (

SUM ( StudentScoreCard[Marks Obtain] ),

SUM ( StudentScoreCard[MaxMarks] )

) * 100

 

After committing, the above DAX Subject %, Lets drag it into table visual as shown below.

If you want to replace blank value with zero, then you can modify above DAX and provide an alternate value, when divide by zero error occurred.

Subject % =

DIVIDE (

SUM ( StudentScoreCard[Marks Obtain] ),

SUM ( StudentScoreCard[MaxMarks] ) ,0

) * 100

As you can see, Blank value is replaced with an alternate value 0.

 





SQL Basics TutorialSQL Advance TutorialSSRSInterview Q & A
SQL Create tableSQL Server Stored ProcedureCreate a New SSRS Project List Of SQL Server basics to Advance Level Interview Q & A
SQL ALTER TABLESQL Server MergeCreate a Shared Data Source in SSRSSQL Server Question & Answer Quiz
SQL DropSQL Server PivotCreate a SSRS Tabular Report / Detail Report
..... More.... More....More
Power BI TutorialAzure TutorialPython TutorialSQL Server Tips & Tricks
Download and Install Power BI DesktopCreate an Azure storage accountLearn Python & ML Step by stepEnable Dark theme in SQL Server Management studio
Connect Power BI to SQL ServerUpload files to Azure storage containerSQL Server Template Explorer
Create Report ToolTip Pages in Power BICreate Azure SQL Database ServerDisplaying line numbers in Query Editor Window
....More....More....More




Loading

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.