Forum Discussion
ValentinBIA
7 years agoResolver I
Filter Count
Good morning Power BI community! I'm running into some problem building my model, and I was wondering is you guys could help. I want to have a Card that gives me the average number of rentals...
- 7 years ago
this should do the trick
Measure = VAR RentalsWithStations = ADDCOLUMNS ( Rentals, "NrOfStations", CALCULATE ( COUNT ( Stations[Station_ID] ), 'Calendar'[Date] <= EARLIER ( Rentals[Date] ) ) ) RETURN SUMX ( GROUPBY ( RentalsWithStations, [NrOfStations], "NrOfRentals", COUNTX ( CURRENTGROUP (), [Rental_ID] ) ), DIVIDE ( [NrOfRentals], [NrOfStations] ) )BTWin your axample Stations has US date format, and Rentals is dd/mm/yyyy, right? Otherwise I cannot reconcile the numbers with your example
- 7 years ago
You may refer to the DAX below.
Measure = SUMX ( SUMMARIZE ( 'Calendar', 'Calendar'[Date].[Year], 'Calendar'[Date].[Month] ), CALCULATE ( DIVIDE ( COUNTROWS ( Rentals ), COUNTROWS ( FILTER ( ALL ( Stations ), Stations[Opening date] <= MAX ( 'Calendar'[Date].[Date] ) ) ) ) ) )
v-chuncz-msft
7 years agoCommunity Support
You may refer to the DAX below.
Measure =
SUMX (
SUMMARIZE ( 'Calendar', 'Calendar'[Date].[Year], 'Calendar'[Date].[Month] ),
CALCULATE (
DIVIDE (
COUNTROWS ( Rentals ),
COUNTROWS (
FILTER (
ALL ( Stations ),
Stations[Opening date] <= MAX ( 'Calendar'[Date].[Date] )
)
)
)
)
)