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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
dariaglb
Frequent Visitor

DAX mesure for row value - coefficients in periods

Hi

I have calendar table and  projects's table with milestones

 

The project has different coefficients in month at different periods of time.

 

Period 2 may  not happen

 

Project

Period 1Period 2Period 3Period 4
Number_101.01.202305.06.202301.09.202310.11.2023
Number_202.03.202310.07.202301.09.2023null
Number_302.03.202323.07.2023nullnull
Number_404.05.202310.12.2023nullnull
Number_1001.10.202312.12.202301.02.2024null
Number_510.10.2023null02.02.2024null

 

I need mesure for calculation coefficients for chart and cards, which depends on Calendar table 
before Periods - coeff - 4/month,
if Period 1 (+) - coeff 5/month,
if Period 2 (+) - coeff - 7/month  after Period 3 (+) - coeff will be 3/month, after Period 4 (+) - coeff will be 1/month,
if Period 2 (-) after Period 3 (+) - coeff will be 1/month, , after Period 4 (+) coeff will be 0

 

dariaglb_0-1726802071228.png

Thanks in advance 🙂 

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@dariaglb , Try below method

 

Create a Calendar Table: Ensure you have a calendar table in your Power BI model.

 

Create Relationships: Make sure your project table is related to the calendar table based on the date fields.

 

Create the Measure: Use the following DAX code to create the measure for calculating the coefficients:

Coefficient Measure =
VAR CurrentDate = MAX('Calendar'[Date])
VAR Period1Date = SELECTEDVALUE('Project'[Period 1])
VAR Period2Date = SELECTEDVALUE('Project'[Period 2])
VAR Period3Date = SELECTEDVALUE('Project'[Period 3])
VAR Period4Date = SELECTEDVALUE('Project'[Period 4])

RETURN
SWITCH(
TRUE(),
CurrentDate < Period1Date, 4,
CurrentDate >= Period1Date && (ISBLANK(Period2Date) || CurrentDate < Period2Date), 5,
CurrentDate >= Period2Date && (ISBLANK(Period3Date) || CurrentDate < Period3Date), 7,
CurrentDate >= Period3Date && (ISBLANK(Period4Date) || CurrentDate < Period4Date),
IF(ISBLANK(Period2Date), 1, 3),
CurrentDate >= Period4Date,
IF(ISBLANK(Period2Date), 0, 1),
0
)

 

 

Conditions:
If the current date is before Period 1, the coefficient is 4.
If the current date is after Period 1 but before Period 2 (or Period 2 is blank), the coefficient is 5.
If the current date is after Period 2 but before Period 3 (or Period 3 is blank), the coefficient is 7.
If the current date is after Period 3 but before Period 4 (or Period 4 is blank), the coefficient is 3 if Period 2 is not blank, otherwise 1.
If the current date is after Period 4, the coefficient is 1 if Period 2 is not blank, otherwise 0.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

2 REPLIES 2
bhanu_gautam
Super User
Super User

@dariaglb , Try below method

 

Create a Calendar Table: Ensure you have a calendar table in your Power BI model.

 

Create Relationships: Make sure your project table is related to the calendar table based on the date fields.

 

Create the Measure: Use the following DAX code to create the measure for calculating the coefficients:

Coefficient Measure =
VAR CurrentDate = MAX('Calendar'[Date])
VAR Period1Date = SELECTEDVALUE('Project'[Period 1])
VAR Period2Date = SELECTEDVALUE('Project'[Period 2])
VAR Period3Date = SELECTEDVALUE('Project'[Period 3])
VAR Period4Date = SELECTEDVALUE('Project'[Period 4])

RETURN
SWITCH(
TRUE(),
CurrentDate < Period1Date, 4,
CurrentDate >= Period1Date && (ISBLANK(Period2Date) || CurrentDate < Period2Date), 5,
CurrentDate >= Period2Date && (ISBLANK(Period3Date) || CurrentDate < Period3Date), 7,
CurrentDate >= Period3Date && (ISBLANK(Period4Date) || CurrentDate < Period4Date),
IF(ISBLANK(Period2Date), 1, 3),
CurrentDate >= Period4Date,
IF(ISBLANK(Period2Date), 0, 1),
0
)

 

 

Conditions:
If the current date is before Period 1, the coefficient is 4.
If the current date is after Period 1 but before Period 2 (or Period 2 is blank), the coefficient is 5.
If the current date is after Period 2 but before Period 3 (or Period 3 is blank), the coefficient is 7.
If the current date is after Period 3 but before Period 4 (or Period 4 is blank), the coefficient is 3 if Period 2 is not blank, otherwise 1.
If the current date is after Period 4, the coefficient is 1 if Period 2 is not blank, otherwise 0.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi, thank you for great solution,

but is it possible to sum coeff of all Projects?
With your mesure chart looks this (is selected one project)

dariaglb_0-1726816641283.png

but if - all selected it looks this

dariaglb_1-1726816727991.png

 



 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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