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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
LMSReportsHelp
Frequent Visitor

Create Measure from data across multiple rows.

I have a set of learning data in which learners are assigned between 1-3 Class names. Because these classes are tied to security roles, they technically have to complete all 3, but the leadership on the training project have decided if they attend ANY of the classes, they should get credit for all of them.

 

In order to create a Registration verification (find anyone NOT registered in a class), I am trying to create a formula which looks at the Student ID and correlates any row in which they ARE registered to show even in rows where they are not. 

So I need to end up with columns like this:

Student IDCourse NameClass IDRegistered?
ABC123Course11234Yes
ABC123Course2 Yes
MNO789Course1 No
MNO789Course2 No
ZYX543Course1 Yes
ZYX543Course2 Yes
ZYX543Course35555Yes

 

I suspect I need to make a variable inside a CALCULATE.  So....

=Calculate(

var CountCourses = COUNTX('TABLE',ALLNOBLANKROW('TABLE'[Class ID]))

var UniqueUser = DISTINCT('TABLE'[User ID})

var TotalRegs = IF(UniqueUser >= [1 CountCourses], "Registered","Not Registered")

RETURN TotalRegs)

 

As you can see - I am not sure how to write that part of my formula.  I suspect there is probably a function I either don't know at all or I just am not seeing the use in this formula.

1 ACCEPTED SOLUTION
v-xuxinyi-msft
Community Support
Community Support

Hi @LMSReportsHelp 

 

Thanks for the reply from @Ashish_Mathur . Here I have another idea in mind, and I would like to share it for reference.

 

@LMSReportsHelp , you can try to create a measure as follows.

Registered? = 
VAR _count = CALCULATE(COUNT('Table'[Student ID]), FILTER(ALLEXCEPT('Table', 'Table'[Student ID]), [Class ID] <> BLANK()))
RETURN
IF(_count <> BLANK(), "Yes", "No")

 

Output:

vxuxinyimsft_0-1720405032282.png

 

Best Regards,
Yulia Xu

 

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

5 REPLIES 5
v-xuxinyi-msft
Community Support
Community Support

Hi @LMSReportsHelp 

 

Thanks for the reply from @Ashish_Mathur . Here I have another idea in mind, and I would like to share it for reference.

 

@LMSReportsHelp , you can try to create a measure as follows.

Registered? = 
VAR _count = CALCULATE(COUNT('Table'[Student ID]), FILTER(ALLEXCEPT('Table', 'Table'[Student ID]), [Class ID] <> BLANK()))
RETURN
IF(_count <> BLANK(), "Yes", "No")

 

Output:

vxuxinyimsft_0-1720405032282.png

 

Best Regards,
Yulia Xu

 

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

Ashish_Mathur
Super User
Super User

Hi,

Write this calculated column formula

Column = if(CALCULATE(CALCULATE(COUNTROWS(Data),Data[Class ID]<>BLANK()),FILTER(Data,Data[Student ID]=EARLIER(Data[Student ID])))>0,"Yes","No")

Hope this helps.

Ashish_Mathur_0-1720234802676.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

The only variation I can think which (haven't been asked for but I can see could be asked for) is instead of "Yes" a count of HOW MANY CLASSES.  THIS project has assigned classes (people can't self-register), but that also allows for human error of accidentally assigning someone to 2+ classes.... Right now the project owner is saying "just yes or no" and in my eyeballing the data I don't see any duplicate assignments - but I can see it happening/being needed.  When I tried to switch "Yes" to a Countrows, I got an error.

Try this

Column = CALCULATE(CALCULATE(COUNTROWS(Data),Data[Class ID]<>BLANK()),FILTER(Data,Data[Student ID]=EARLIER(Data[Student ID])))

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Try this

Column = CALCULATE(CALCULATE(COUNTROWS(Data),Data[Class ID]<>BLANK()),FILTER(Data,Data[Student ID]=EARLIER(Data[Student ID])))

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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