Dax code for calculated columns

0 votes

I have sample data

person-id,person-name,course-name,event,event-rank,startDT,stopDT
11, John, CS101, enrol,1,2000-01-01,2000-03-31
11, John, CS101, grant,2,2000-04-01,2000-04-30
11, John, CS101, cancel,3,2000-04-01,2000-04-30
11, John, PHIL, enrol, 1, 2000-02-01,2000-03-31
11, John, PHIL, grant, 2, 2000-04-01,2000-04-30

Here the columns represent number of actions, student name, their course names, course action- enroll, cancel or grant and the from-to dates for filtering purpose. There is a need for adding the number for distinct student and course, the composite key . How to add this to the code?

Oct 22, 2018 in Power BI by lina
• 8,220 points
1,119 views

1 answer to this question.

0 votes
I would recommend you to adjust the data model than adding the cancellation logic to your dax.
answered Oct 22, 2018 by Hannah
• 18,520 points
Could you please elaborate a little more or explain with an example?

For example, if you could add a column to your data model that flags a row as subsequently cancelled, then all DAX has to do is check that flag to know if an action is cancelled or not. A CALCULATE statement. You don't have to have lots of logic to determine whether the event was cancelled. You entirely eliminate the need for SUMX, which can be slow when working with a lot of rows since it works row by row.

Related Questions In Power BI

0 votes
0 answers
+2 votes
1 answer

What are the best practices for creating calculated columns versus measures in Power BI?

Use Calculated Columns for Static Row-Level Calculations. ...READ MORE

answered Oct 21 in Power BI by pooja
• 4,690 points
69 views
0 votes
0 answers
0 votes
1 answer

What strategies do you use for writing efficient DAX code to handle large fact tables with millions of rows?

In Data Analytics eXpressions (DAX), when dealing ...READ MORE

answered Oct 29 in Power BI by pooja
• 4,690 points
121 views
+3 votes
2 answers

Combine tables in Power BI

You can also achieve this using a ...READ MORE

answered Oct 5, 2018 in Power BI by lina
• 8,220 points

edited Oct 11, 2018 by Kalgi 2,464 views
0 votes
1 answer

Power Bi Dax Table

You need to wrap the numbers in ...READ MORE

answered Oct 5, 2018 in Power BI by Kalgi
• 52,350 points
1,157 views
0 votes
2 answers

Power BI Dax Multiple IF AND Statements

HI I have Column Patient 12 13 14 15 18 IN Patient=12, 13 Out ...READ MORE

answered May 23, 2019 in Power BI by VNK
18,936 views
0 votes
1 answer

Distinct count filtered by condition using Power BI Dax

Try this, it should work: DistinctCountActiveMonths = CALCULATE( ...READ MORE

answered Oct 5, 2018 in Power BI by Kalgi
• 52,350 points
37,639 views
0 votes
1 answer

list reports with calculated percentage in Power BI using dax

Create a Measure called Total Revenue: Total Revenue = SUMX( ...READ MORE

answered Oct 22, 2018 in Power BI by Hannah
• 18,520 points
1,620 views
0 votes
1 answer

What options do I have for viewing and working with data on premises

There are three ways to achieve the ...READ MORE

answered Oct 15, 2018 in Power BI by Hannah
• 18,520 points
670 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP