Forum Discussion
Active dealer count
- 3 years ago
Thank you sir for your all valuable suggestions this is done by this measure
Active Customers = VAR SummaryTable = ADDCOLUMNS ( SUMMARIZE ( CUBE_INVOICE, CUBE_INVOICE[SOLD TO PARTNER.PARTNER CODE]), "@num months", COUNTROWS ( CALCULATETABLE ( SUMMARIZE ( CUBE_INVOICE, Calendar_new[YM] ) ) ) ) RETURN COUNTROWS ( FILTER ( SummaryTable, [@num months] >= 3 ) )This measure working when we selecct more than 3 month on calender slicer but with this measure we done it for ficial year
Active dealer in ficial year = CALCULATE([Active Customers],DATESYTD(Calendar_new[Date],"03/31"))
Hi , SachinNamdeo-20
According to your description, you want to calculate the count of active users who have more than 3 sales in different month.
For your table , it not a good data structure to dispose the data.
Here are the steps you can refer to :
(1)This is my test data:
(2)We need to convert the table in Power Query Editor, You can put the M code in "Advanced Editor" to refer to :
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc3LCYBADATQXnIeMIl7sJfFQ/whgiIerMdarMy4oisJmcsbEiNJIYWyKoEmW87D09Cg9RSGMkqmGpE0u6FvXoXu5xAeWmY629aOCe8PR/8VJIAVcm+qhVyzdfPr2Mf+Hyqn9QU=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [date = _t, month = _t, dealer = _t, sales = _t]),
Custom1 = Table.TransformColumns(Source,{{"dealer",(x)=>Text.Split(x,",")},{"sales",(x)=>Text.Split(x,",")}}),
#"Added Custom" = Table.AddColumn(Custom1, "Custom", each Table.FromColumns({[dealer],[sales]},{"dealer","sales"})),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"dealer", "sales"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"dealer", "sales"}, {"dealer", "sales"})
in
#"Expanded Custom"
The result table is like this:
(3)Then we can apply the data to Desktop and then we can click "New column" to add a [Year_month] column in our table as a dimension:
Year_month = year([Date]) * 100 + MONTH([Date])
(4)Then we can create a measure like this:
Count = var _t = ALLSELECTED('Table')
var _t2 =SUMMARIZE(_t ,[Year_month],[dealer])
var _t3 =FILTER(ADDCOLUMNS(_t2 ,"count" ,var _dealer = [dealer] return COUNTROWS(FILTER(_t2 ,[dealer]=_dealer))) , [count]>3)
return
COUNTROWS(DISTINCT(SELECTCOLUMNS(_t3, "dealer" ,[dealer])))
Then we can meet your need:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thank you sir for your all valuable suggestions this is done by this measure
Active Customers =
VAR SummaryTable =
ADDCOLUMNS (
SUMMARIZE ( CUBE_INVOICE, CUBE_INVOICE[SOLD TO PARTNER.PARTNER CODE]),
"@num months", COUNTROWS ( CALCULATETABLE ( SUMMARIZE ( CUBE_INVOICE, Calendar_new[YM] ) ) )
)
RETURN COUNTROWS ( FILTER ( SummaryTable, [@num months] >= 3 ) )This measure working when we selecct more than 3 month on calender slicer but with this measure we done it for ficial year
Active dealer in ficial year = CALCULATE([Active Customers],DATESYTD(Calendar_new[Date],"03/31"))