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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Hariharan_R
Solution Sage
Solution Sage

Filter and Dynamic Result

Hi 

 

  I have below tables and i need to get "Default/Bonus" (red colour columns) column on Trans table. Also mentioned the logic for the columns.

 

  We will be using RLS to filter the student.

 

Time.png

11 REPLIES 11
Ashish_Mathur
Super User
Super User

Hi,

Create this calculated column formula in the Trans Table

=IF(CALCULATE(COUNTROWS(Score),FILTER(Score,Score[StartDate]<=EARLIER(Trans[CourseDateTime])&&Score[EndDate]>=EARLIER(Trans[CourseDateTime])))>0,CALCULATE(SUM(Score[Bonus]),FILTER(Score,Score[StartDate]<=EARLIER(Trans[CourseDateTime])&&Score[EndDate]>=EARLIER(Trans[CourseDateTime]))),CALCULATE(SUM(Score[Default]),FILTER(Score,Score[StartDate]<=EARLIER(Trans[CourseDateTime])&&Score[EndDate]>=EARLIER(Trans[CourseDateTime]))))

Hope this helps.


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

It is not giving the expected result. 

 

Score table's year and Trans table's year should be considered and the value is based on the student logs in. if student B logsin then subject S2 only considered on the Trans table new columns.

 

Your script showing below result.

Time1.png

Hi,

Share data from both tables such that i can paste those in an Excel file.  Also, show the exact result you are expecting.


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

Hi

 

Table: Subject

Subject
StudentSubject
AS1
BS2
CS1

 

Score
StartDateEndDateYearDefaultBonusSubject
3/1/2019 1:003/3/2019 4:00201956S1
2/1/2018 1:004/4/2018 4:0020181110S1
4/1/2019 1:004/3/2019 4:00201942S2
2/1/2018 1:003/6/2018 4:0020181213S2

 

IDCourseDateTime
13/1/2019 2:00
23/1/2019 3:00
13/3/2019 3:00
23/4/2019 3:00
33/4/2019 0:00
43/4/2018 0:00
51/1/2018 1:00


If Student
A logs in the below result.
Expected result is as like below.

IDCourseDateTimeDefault/BonusCourseDateTime + (Default/Bonus)
13/1/2019 2:0063/1/2019 8:00
23/1/2019 3:0063/1/2019 9:00
13/3/2019 3:0063/1/2019 9:00
23/4/2019 3:0053/4/2019 9:00
33/4/2019 0:0053/4/2019 5:00
43/4/2018 0:00103/4/2018 10:00
51/1/2018 1:00111/1/2018 0:00

 

 

If Student B logs in

IDCourseDateTimeDefault/BonusCourseDateTime + (Default/Bonus)
13/1/2019 2:0043/1/2019 6:00
23/1/2019 3:0043/1/2019 7:00
13/3/2019 3:0043/1/2019 7:00
23/4/2019 3:0043/4/2019 7:00
33/4/2019 0:0043/4/2019 4:00
43/4/2018 0:00133/4/2018 13:00
51/1/2018 1:00121/1/2018 13:00

 

The logic for the Default /Bonus column should be

 

if(CourseDateTime>Score.StartDate
&& CourseDateTime<Score.EndDate, Bonus, Default)

Hi,

Are the dates in dd/mm/yyyy or mm/dd/yyyy format?


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

Hi 

 

  dates are in mm/dd/yyyy format.

 

Thanks

Hi,

In the third table, there is no Student/Subject column.  So then how would we know what default/bonus column rule to apply.


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

Hi

 

   Third tables datetime column should compare with score table.

 

For example, if third table's datetime value is between the score.StartDate and Score.EndDate then Bonus value else default value. It also should consider the year of third table and year of score table.

 

condition - if(CourseDateTime>Score.StartDate
&& CourseDateTime<Score.EndDate, Bonus, Default)

Can anyone achieve this?

Anonymous
Not applicable

Create a measure in Trans and copy paste following dax:

 

Measure = IF(MAX(Trans[CourseDateTime])>MAX(Score[Startdate])&& MAX(Trans[CourseDateTime])<MAX(Score[Enddate]),MAX(Score[Bonus]),MAX(Score[Default]))
 
Let me know if that helps. 🙂

It is not giving the expected result. 

 

Score table's year and Trans table's year should be considered and the value is based on the student logs in. if student B logs in then subject S2 only considered on the Trans table new columns.

 

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors