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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX formula error when using Addcolumn and Groupby

 

Hi Expert

I cannot see the error here in terms of what i am doing wrong when writing the following DAX.

DAX

Concordant = 
VAR __table = ADDCOLUMNS(VALUES(PMS_COMPLAINT[FISCAL_MON_START_DT]),"CountComplaints", CALCULATE(COUNTROWS(PMS_COMPLAINT)),"__Index",RANKX(PMS_COMPLAINT,PMS_COMPLAINT[FISCAL_MON_START_DT],,,Dense))
VAR __table1 = FILTER(__table,[__Index]>EARLIER([__Index])&&[CountComplaints]>EARLIER([CountComplaints]))
VAR __count = COUNTROWS(__table1)
RETURN
IF(ISBLANK(__count),0,__count)

 

Error Message

error_message.PNG

1 ACCEPTED SOLUTION

Hi  @Anonymous ,

 

Take try of this one:

 

Concordant = 
VAR __table = ADDCOLUMNS(VALUES(PMS_COMPLAINT[FISCAL_MON_START_DT]),"CountComplaints", CALCULATE(COUNTROWS(PMS_COMPLAINT)),"__Index",RANKX(PMS_COMPLAINT,PMS_COMPLAINT[FISCAL_MON_START_DT],,,Dense))
VAR __count = CALCULATE(COUNTROWS(__table),FILTER(__table,[__Index]<=MAX([__Index])&&[CountComplaints]<=MAX([CountComplaints])))
RETURN
IF(ISBLANK(__count),0,__count)

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

11 REPLIES 11
Anonymous
Not applicable

Hi Experts

 

Cannot see the wood for the trees on what i am doing wrong with the following DAX (variable formula).

Concordant = 
VAR ComplaintsByFiscalMo = ADDCOLUMNS(VALUES(PMS_COMPLAINT[FISCAL_MON_START_DT]),"CountComplaints", CALCULATE(COUNTROWS(PMS_COMPLAINT)))
VAR __table = GROUPBY(ComplaintsByFiscalMo,"Index",RANKX(CURRENTGROUP(),[FISCAL_MON_START_DT],,,Dense))
VAR __table1 = FILTER(__table,[Index]>EARLIER([Index])&&[CountComplaints]>EARLIER([CountComplaints]))
VAR __count = COUNTROWS(__table1)
RETURN
IF(ISBLANK(__count),0,__count)

Hi,

 

Same question here, please refer to https://community.powerbi.com/t5/Desktop/DAX-formula-error-when-using-Addcolumn-and-Groupby/td-p/764...

 

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

What's the error you are getting? I'm going to guess that the issue is your use of EARLIER. EARLIER references the previous context, which doesnt look like you have one, but just a guess w/o knowing the error and seeing the data. 

Anonymous
Not applicable

Nick_M

 

That is correct. Earlier , earlier...as mentioned in your reply.

Anonymous
Not applicable

you need to tell earlier what to reference. Can try wrapping an ALL around the table and see if that would work. But would be easier if you can upload some sample data with the required output. 

Anonymous
Not applicable

i am referring to the folloiwing Kendall's Tau Quick Measure here https://community.powerbi.com/t5/Quick-Measures-Gallery/Kendall-s-Tau/m-p/625107

 

I am trying to re create the same calculation using my dataset. Sample file attached. I am trying to get the tau

 

The values i would like to use from my data set are Material_id and FISCAL_MON_START_DT as the two variables. Which find these in the main FACT table PMS_Complaints.

 

The answer lie with the greg decker link on how you can implement the measure....he uses two variables and sorts the data interviewer 1 and 2. I want to implement the same principles with my data using variables as I mentioned in above post...

 

Smaple Data File

https://www.dropbox.com/s/i0nffe5gso2d684/Sample__.pbix?dl=0

 

for required output see tau value in image (below)

currently my tau value is 0.186441 as you will see from first tab when you open up pBIX file. i am trying to make this measure dynamic.

tau.PNG

 

 

Anonymous
Not applicable

Anonymous
Not applicable

hang fire uploading sample data and required output.

Anonymous
Not applicable

 

if i add ALL before filter i getting the following error.

 

error_message.PNG

Hi  @Anonymous ,

 

Take try of this one:

 

Concordant = 
VAR __table = ADDCOLUMNS(VALUES(PMS_COMPLAINT[FISCAL_MON_START_DT]),"CountComplaints", CALCULATE(COUNTROWS(PMS_COMPLAINT)),"__Index",RANKX(PMS_COMPLAINT,PMS_COMPLAINT[FISCAL_MON_START_DT],,,Dense))
VAR __count = CALCULATE(COUNTROWS(__table),FILTER(__table,[__Index]<=MAX([__Index])&&[CountComplaints]<=MAX([CountComplaints])))
RETURN
IF(ISBLANK(__count),0,__count)

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

many thanks -Dina

 

excellent feedback as always much appreciated.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.