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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
manojk_pbi
Helper IV
Helper IV

Help need to write dax measure

Hi,

 

I have 2 tables, one with tasks details by project and another is cost% by projects. I need to create a visualization to show the Net change in the tasks Month on Month by Project and another table to show Netchange with respect to cost share (NetChange * Cost%).

 

Appreciate any suggestions or sample code for DAX

 

Data tables 

Table 1  
ProjectDateTasks
Project1Jan'24120
Project2Jan'24100
Project3Jan'24130
Project1Feb'24110
Project2Feb'2490
Project3Feb'24100
Project1Mar'2480
Project2Mar'2480
Project3Mar'24145
Project1Apr'2495
Project2Apr'2475
Project3Apr'24125
   
Table 2   
ProjectCost% 
Project126% 
Project235% 
Project339% 

 

 

required output:

Table1 for display   
ProjectJan'24Feb'24Mar'24Apr'24
Project11201108095
Project2100908075
Project3130100145125

 

Net Change : Baseline month - current month eg Jan'24-Feb'24 , Jan'24 - Mar'24, Jan'24 - Apr'24

ProjectJan'24Feb'24Mar'24Apr'24
Project1 104025
Project2 102025
Project3 30-155

 

Net Change * Cost% : for Project1 Feb'24 = 10*26%

ProjectJan'24Feb'24Mar'24Apr'24
Project1 3107
Project2 479
Project3 12-62
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @manojk_pbi ,

Because Power BI sorts by default based on alphabetical order, we need to create a sort table

vyangliumsft_0-1714012124435.png

Here are the steps you can follow:

1. Create calculated table

Date =
var _date=
CALENDAR(
    DATE(2024,1,1),
    DATE(2024,12,31))
return
ADDCOLUMNS(
    _date,"MonthYear",FORMAT([Date],"mmm")&"'"&FORMAT([Date],"yy"))

vyangliumsft_1-1714012124437.png

Sort_Table =
SUMMARIZE('Date','Date'[MonthYear],"mindate",MINX(FILTER(ALL('Date'),'Date'[MonthYear]=EARLIER('Date'[MonthYear])),[Date]))

vyangliumsft_2-1714012156917.png

2. Select [MonthYear] – Column tools – Sort by column – [mindate].

vyangliumsft_3-1714012156920.png3. Joining two tables.

vyangliumsft_4-1714012179384.png

vyangliumsft_5-1714012179388.png

4. Create measure.

Baseline month - current month =
var _today=TODAY()
var _monthyear=MINX(FILTER(ALL('Date'),'Date'[Date]=DATE(YEAR(_today),1,1)),[MonthYear])
var _value=SUMX(FILTER(ALL('Table'),'Table'[Project]=MAX('Table'[Project])&&'Table'[Date]=_monthyear),[Tasks])
RETURN
_value - MAX('Table'[Tasks])

vyangliumsft_6-1714012206747.png

Net Change * Cost% =
var _value=
SUMX(FILTER(ALL('Table2'),
'Table2'[Project]=MAX('Table'[Project])),[Cost%])
return
_value * [Baseline month - current month]

vyangliumsft_7-1714012206751.png

 

 

Best Regards,

Liu Yang

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

2 REPLIES 2
Anonymous
Not applicable

Hi  @manojk_pbi ,

Because Power BI sorts by default based on alphabetical order, we need to create a sort table

vyangliumsft_0-1714012124435.png

Here are the steps you can follow:

1. Create calculated table

Date =
var _date=
CALENDAR(
    DATE(2024,1,1),
    DATE(2024,12,31))
return
ADDCOLUMNS(
    _date,"MonthYear",FORMAT([Date],"mmm")&"'"&FORMAT([Date],"yy"))

vyangliumsft_1-1714012124437.png

Sort_Table =
SUMMARIZE('Date','Date'[MonthYear],"mindate",MINX(FILTER(ALL('Date'),'Date'[MonthYear]=EARLIER('Date'[MonthYear])),[Date]))

vyangliumsft_2-1714012156917.png

2. Select [MonthYear] – Column tools – Sort by column – [mindate].

vyangliumsft_3-1714012156920.png3. Joining two tables.

vyangliumsft_4-1714012179384.png

vyangliumsft_5-1714012179388.png

4. Create measure.

Baseline month - current month =
var _today=TODAY()
var _monthyear=MINX(FILTER(ALL('Date'),'Date'[Date]=DATE(YEAR(_today),1,1)),[MonthYear])
var _value=SUMX(FILTER(ALL('Table'),'Table'[Project]=MAX('Table'[Project])&&'Table'[Date]=_monthyear),[Tasks])
RETURN
_value - MAX('Table'[Tasks])

vyangliumsft_6-1714012206747.png

Net Change * Cost% =
var _value=
SUMX(FILTER(ALL('Table2'),
'Table2'[Project]=MAX('Table'[Project])),[Cost%])
return
_value * [Baseline month - current month]

vyangliumsft_7-1714012206751.png

 

 

Best Regards,

Liu Yang

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

@Anonymous , thanks for your quick response. I will check and try to understand your suggestion.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.