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

Need help with DAX logic

Hello Everyone, 

 

I need your help. 

I have a table with Students being out for certain days in a week as shown below:

 

Jess90_1-1662582312174.png

 

I would like to create a DAX expression to get similar result.

If you have any idea pls share, thank you in advance. 

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

Hi @Anonymous ,

 

Like this?

vmengzhumsft_0-1662607597340.png

You just need to create a cloumn:

Rate = var _count=CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Student]=EARLIER('Table'[Student])))
return IF(_count=5,"High",IF(_count>1,"Medium",IF(_count=1,"Low")))

 

And then through conditonal formatting to get the color you want.

Refer my pbix file for better understanding.

 

Best regards,

Community Support Team Selina zhu

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

4 REPLIES 4
v-mengzhu-msft
Community Support
Community Support

Hi @Anonymous ,

 

Like this?

vmengzhumsft_0-1662607597340.png

You just need to create a cloumn:

Rate = var _count=CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Student]=EARLIER('Table'[Student])))
return IF(_count=5,"High",IF(_count>1,"Medium",IF(_count=1,"Low")))

 

And then through conditonal formatting to get the color you want.

Refer my pbix file for better understanding.

 

Best regards,

Community Support Team Selina zhu

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

 

amitchandak
Super User
Super User

@Anonymous , Do you have any date?

else try like

 

new column =

var _1 = countx(filter(Table, [Day] =earlier([Day]) && [Student] = earlier([Student]) ), [Student])

var _2 = countx(filter(Table, [Day] =earlier([Day]) && [Student] = earlier([Student]) && [Status] ="Out"), [Student])

Var _3 = distinctcount(Table[Day])

return

Switch(True() ,

_2 =_3, "High",

_2 =1, "Low",

"Medium"

)

 

Anonymous
Not applicable

Hey @amitchandak,

 

Thanks for the solution, it very close to what I was looking for.

I do have date column, where to use it if I want to see year to date (YTD) data? 

Hi @Anonymous ,

 

Have you seen my reply? Can it meet your needs?

 

Best regards,

Community Support Team Selina zhu

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

 

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.

Top Solution Authors