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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

DAX Measure for Active Contracts based on a value

Hello! 

 

I'm new to Power BI so please ask if what I'm trying to do is not understandable. 

 

I have a table with Contracts and I've made a measure to show me the active contracts from day to day. This is the measure I've used, and it's working and gives med the active contracts from day to day. 

"CALCULATE(COUNTROWS(Contracts); FILTER(Contracts; Contracts[Start Date] <= LASTDATE('Date'[Date]) && [Column] >= FIRSTDATE('Date'[Date])))"

 

I've put this into a line diagram to show progress over time. 

These contracts are in different areas. The areas are listed in a Column inside the same table as Contracts. I've grouped them into 3 groups, and what I want to do, is to have one line in the diagram for each of the areas, in addition to the line that shows total active contracts. 


How can I create a measure based on those specific values? Is there a better way to do it? Do I add something to the measure I already have, based on that specific group?

 

Thank you in advance for the help!  

 

4 REPLIES 4

Hello Siljewiehauge,

 

You can change your measure to be like below:

Day to day = calculate(COUNTROWS(Contracts),filter(ALL(Contracts[Start Date]),Contracts[Start Date]<=MAX(Contracts[Start Date])))
 
So by adding the measure to values and dates to axis you will get below visual:
1.PNG
 
 
 If you want to get line for each contract type; just add contract type to legend and you will get below chart
2.PNG
 
Hope thats answering your question 🙂
 
Please don't hesitate to ask if anything else.
Best wishes.
Anonymous
Not applicable

 

Hello, and thank you! I've already done that, with the measure that I have. And I have the Active Contracts in a line diagram, it's working.

 

When I try to add Grid Owner Name to legend, it's not working. Somehow the line flattens out.

And anyway I would need one line for total, than one line for each of those. 

 

So I thought if I could create one measure for total active contracts, as I already have; 

then one measure that used the same calculation, but only based on rows with the correct Grid owner name? Is that possible? 

 

 

 

 

Unfortunetaly, line chart can have only one measure.

 

However, there is a hack to do that:

1 . In Power Query window: copy you query

2 . Replace each contract type with the word "All"

3 . Append quiries together.

 

By doing those steps you will have doublicate data in your table with contract type called All 

 

Hope that's helps you.

Best wishes.

 

----------------------------------------------

Did I answer your question? Mark my post as a solution! 

Greg_Deckler
Community Champion
Community Champion

Tough to follow. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.