Forum Discussion
Dynamic Calculated Column based on Slicer
yes, but it depends on what you want to achive. Do you want a list of customers and which category they are in, or the count of customers pr category? Or filter on a category?
I want to be able to see the count of customer in each category and then use the category as a filter.
- sturlaws6 years agoResident Rockstar
If you have a separate table,Categories, with 1 column,Category, and Poor, Average and Good on the rows, create a measure like this:
countPrCategory = SWITCH ( TRUE (); SELECTEDVALUE ( 'Categories'[Category] ) = "Poor"; CALCULATE ( DISTINCTCOUNT ( Table[customerID] ); FILTER ( Table; ISBLANK ( Table[clearing date] ) || [paysegcheck] = 1 ) ); SELECTEDVALUE ( 'Categories'[Category] ) = "Average"; CALCULATE ( DISTINCTCOUNT ( Table[customerID] ); FILTER ( Table; [paysegcheck] = 0 ) ); SELECTEDVALUE ( 'Categories'[Category] ) = "Good"; CALCULATE ( DISTINCTCOUNT ( Table[customerID] ); FILTER ( Table; [days to pay] <= 0 ) ); 0 )
If you also want to filter on these categories, add this measure to the filter part of the visual(s), and set it to greater than 0 - v-lid-msft6 years agoCommunity Support
Hi Anonymous ,
The measure is dynamic but the calculated columns are computed during the database processing and then stored in the model. So In your scenario, we cannot make the calculated column dynamically.
If you want to give customer a type depends on another measure, you can try the following steps.
Create a table contain all the types
create a measure to count by type
TypeCount = COUNTROWS ( FILTER ( ADDCOLUMNS ( ALL ( FinalImport ), "Type", IF ( 'FinalImport'[Clearing Date] = BLANK (), "3.Poor Payers", IF ( [DAYS TO PAY] <= 0, "1.Good Payers - On Time", IF ( [paysegcheck] = 0, "2.Average Payers", IF ( [paysegcheck] = 1, "3.Poor Payers" ) ) ) ) ), [Type] = SELECTEDVALUE ( TypeTable[Type] ) ) )The "check" slicer control the measure paysegcheck
BTW, pbix as attached.
Best regards,
Community Support Team _ DongLi
If this post helps, then please consider Accept it as the solution to help the other members find it more- sturlaws6 years agoResident Rockstar
Anonymous,
out of curiosity, what does the code for you measure [paysegcheck] look like?- Anonymous6 years agoNot applicableI think this is also part of my problem, I need to consider the days to pay for each order seperately, so I think my calculation below is probably incorrect paysegcheck = IF(SUM(FinalImport[DAYS TO PAY]) - [Interval Value] <0, 1, 0)