Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext 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
Hello.
I have some data that looks like this:
| SOW | Work Week Number |
| 2003 | 9 |
| 2003 | 9 |
| 2003 | 9 |
| 2007 | 9 |
| 2007 | 9 |
| 7921 | 9 |
| 7913 | 9 |
| 2003 | 10 |
| 2003 | 10 |
| 2003 | 10 |
| 2007 | 10 |
| 2007 | 10 |
| 7921 | 10 |
| 2003 | 11 |
| 2003 | 11 |
| 2003 | 11 |
| 2003 | 11 |
| 2003 | 11 |
| 2007 | 11 |
| 2007 | 11 |
| 7921 | 11 |
| 2003 | 12 |
| 2003 | 12 |
| 2003 | 12 |
| 2003 | 12 |
| 2003 | 12 |
| 11661 | 12 |
| 11661 | 12 |
| 2003 | 13 |
| 2003 | 13 |
| 2003 | 13 |
| 2007 | 13 |
| 2007 | 13 |
| 7921 | 13 |
| 11661 | 13 |
| 11661 | 13 |
| 11661 | 13 |
| 11661 | 13 |
| 11661 | 13 |
| 11661 | 13 |
| 11661 | 13 |
| 2003 | 14 |
| 2003 | 14 |
| 2003 | 14 |
| 2003 | 14 |
| 2007 | 14 |
| 2007 | 14 |
| 7921 | 14 |
| 11661 | 14 |
| 11661 | 14 |
| 11661 | 14 |
| 11661 | 14 |
| 2003 | 15 |
| 2003 | 15 |
| 2003 | 15 |
| 2007 | 15 |
| 2007 | 15 |
| 7921 | 15 |
| 11371 | 15 |
| 11371 | 15 |
| 11371 | 15 |
| 11661 | 15 |
| 11661 | 15 |
| 11661 | 15 |
| 11661 | 15 |
| 2003 | 16 |
| 2003 | 16 |
| 2007 | 16 |
| 2007 | 16 |
| 7921 | 16 |
| 11371 | 16 |
| 11371 | 16 |
| 11371 | 16 |
| 11371 | 16 |
| 11661 | 16 |
| 11661 | 16 |
| 11661 | 16 |
There are multiple instances of a scope number, along with the work week that the data was pulled.
I want to a count of how many scopes are added each week, which would be a unique count of the first instance of the SOW.
I'm hoping for results that look like this:
| SOW | Work Week Number | First Instance |
| 2003 | 9 | 1 |
| 2007 | 9 | 1 |
| 7913 | 9 | 1 |
| 7921 | 9 | 1 |
| 11661 | 12 | 1 |
| 11371 | 15 | 1 |
In this example, I would have 4 new SOW in work week 9, 1 in work week 12 and 1 in work week 15.
What is the best way to accomplish this?
Thanks.
Solved! Go to Solution.
Hi @Anonymous
Here is a measure that should do what you are looking for (replace Data with your actual table name):
First Instance =
VAR SOW_FirstWorkWeek =
ADDCOLUMNS (
VALUES ( Data[SOW] ),
"@FirstInstance",
CALCULATE ( MIN ( Data[Work Week Number] ), ALLEXCEPT ( Data, Data[SOW] ) )
)
VAR SOW_FirstWorkWeekWithLineage =
TREATAS (
SOW_FirstWorkWeek,
Data[SOW],
Data[Work Week Number]
)
RETURN
CALCULATE (
DISTINCTCOUNT ( Data[SOW] ),
KEEPFILTERS ( SOW_FirstWorkWeekWithLineage )
)
This is a similar pattern to some of the measures on Semi-additive calculations - DAX Patterns
Regards,
Owen
This worked beautifully. Thank you.
Hi @Anonymous
Here is a measure that should do what you are looking for (replace Data with your actual table name):
First Instance =
VAR SOW_FirstWorkWeek =
ADDCOLUMNS (
VALUES ( Data[SOW] ),
"@FirstInstance",
CALCULATE ( MIN ( Data[Work Week Number] ), ALLEXCEPT ( Data, Data[SOW] ) )
)
VAR SOW_FirstWorkWeekWithLineage =
TREATAS (
SOW_FirstWorkWeek,
Data[SOW],
Data[Work Week Number]
)
RETURN
CALCULATE (
DISTINCTCOUNT ( Data[SOW] ),
KEEPFILTERS ( SOW_FirstWorkWeekWithLineage )
)
This is a similar pattern to some of the measures on Semi-additive calculations - DAX Patterns
Regards,
Owen
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 43 | |
| 39 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 63 | |
| 32 | |
| 30 | |
| 23 |