March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I have a dataset similar to this:
Export Date | Risk ID | Tower |
06/06/2021 | RID1 | Tower A |
06/06/2021 | RID2 | Tower A |
07/07/2021 | RID1 | Tower A |
07/07/2021 | RID2 | Tower A |
07/07/2021 | RID3 | Tower A |
08/08/2021 | RID1 | Tower A |
08/08/2021 | RID2 | Tower A |
08/08/2021 | RID3 | Tower A |
08/08/2021 | RID4 | Tower A |
I am wanting to create a calculatedcolumn that lets me know if a new Risk ID has been added per month. So the output should be
June = 0
July = 1
August = 1
Is there a way I can do this by month and another calculated column that does this by week?
Solved! Go to Solution.
Yes, you can do as calculated column too.
Earliest New Item Within Tower =
var _RID = Table1[Risk ID]
var _Twr = Table1[Tower]
var _FirstDate = CALCULATE( Min(Table1[Export Date]), filter(Table1, Table1[Risk ID] = _RID && Table1[Tower] = _Twr))
RETURN IF ( Table1[Export Date] = _FirstDate, 1, 0)
additional reading: I am not sure the end goal of the final model. I recommend to look:
To add ranking calculated column and then use for your needs.
https://community.powerbi.com/t5/Desktop/Summarize-and-Rank-by-multiple-columns-and-rows/m-p/330108
https://community.powerbi.com/t5/Desktop/Rank-from-Min-to-MAX-Calculated-Column/m-p/1793486
If it is me, I will not do as calculated column for min max by category. I will recommend as aggregate table using M Query. Purely depends on your needs and design way of things.
https://www.ehansalytics.com/blog/2020/7/16/return-row-based-on-max-value-from-one-column-when-group...
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
For week, you can use the same measure, all you need to use is the Week from Date table.
I guess you are looking "New Customers" pattern. (and not returning customers pattern)
See if this will work for you:
For testing, I created as
Date table as (you may be having the table)
Date =
var _cal = CALENDAR(MIN(Table1[Export Date]), Max(Table1[Export Date]))
RETURN ADDCOLUMNS(
_cal,
"Year", YEAR( [Date]),
"Month Number", MONTH( [Date]),
"Month", FORMAT([Date], "MMMM")
)
Added MEASURE New Items
NewItems =
COUNTROWS (
FILTER (
CALCULATETABLE (
ADDCOLUMNS (
VALUES ( Table1[Risk ID] ),
"DateOfFirstItem", CALCULATE ( MIN ( Table1[Export Date] ) )
),
ALL ( 'Date' )
),
CONTAINS (
VALUES ( 'Date'[Date] ),
'Date'[Date],
[DateOfFirstItem]
)
)
)
Additional reading:
Below links has details about it
https://radacad.com/customer-retention-in-power-bi-dax-measures
https://www.daxpatterns.com/new-and-returning-customers/
https://blog.enterprisedna.co/new-vs-existing-customers-advanced-analytics-w-dax/
https://www.sqlbi.com/articles/computing-new-customers-in-dax/
@sevenhills Instead of having a measure, is there a way to create a calculated column that assignes a 1 next to the new entries? If so that would be brilliant!
Thanks again 🙂
Yes, you can do as calculated column too.
Earliest New Item Within Tower =
var _RID = Table1[Risk ID]
var _Twr = Table1[Tower]
var _FirstDate = CALCULATE( Min(Table1[Export Date]), filter(Table1, Table1[Risk ID] = _RID && Table1[Tower] = _Twr))
RETURN IF ( Table1[Export Date] = _FirstDate, 1, 0)
additional reading: I am not sure the end goal of the final model. I recommend to look:
To add ranking calculated column and then use for your needs.
https://community.powerbi.com/t5/Desktop/Summarize-and-Rank-by-multiple-columns-and-rows/m-p/330108
https://community.powerbi.com/t5/Desktop/Rank-from-Min-to-MAX-Calculated-Column/m-p/1793486
If it is me, I will not do as calculated column for min max by category. I will recommend as aggregate table using M Query. Purely depends on your needs and design way of things.
https://www.ehansalytics.com/blog/2020/7/16/return-row-based-on-max-value-from-one-column-when-group...
This works perfectly, thank you!!
Hi @sevenhills , thank you for this!
Is there a way to add a filter into this too? The 'Tower' column has multiple towers in my dataset and so I want to be able to filter by each individual one?
Thanks again!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
143 | |
97 | |
79 | |
68 |