The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I didn't find out a post about it although I think at least one people were face to face with this situation.
Exemple :
Historique (customers with statuts in each period) "d_client_histo"
client_id | start_date | end_date | status |
200 | 01/01/2020 | 01/06/2022 | CLUB |
200 | 01/06/2022 | 01/01/2100 | OR |
100 | 01/02/2021 | 01/01/2100 | CLUB |
I got table DATE with relations DATE[date]=>start_date and DATE[date]=>end_date (only one active obviously)
And I got a table with all the status with his level
If one customer pass by a level over the CLUB's level -> his status-type is VIP
I would like to get these results :
If I choose year=2022
client_id | statuts_type |
100 | CLUB |
200 | VIP |
If I choose 2021
client_id | statuts_type |
100 | CLUB |
200 | CLUB |
I tried this measure :
Thank you all
Solved! Go to Solution.
Hi @bapt69 ,
Here I suggest you to create an unrelated calendar table to help you calculate the status.
Data model:
Measure:
Status_Type =
VAR _RANGESTART =
MIN ( 'Calendar'[Date] )
VAR _RANGEEND =
MAX ( 'Calendar'[Date] )
VAR _STATUSLIST =
CALCULATETABLE (
VALUES ( d_client_histo[status] ),
FILTER (
ALLEXCEPT ( d_client_histo, d_client_histo[client_id] ),
d_client_histo[start_date] <= _RANGEEND
&& d_client_histo[end_date] >= _RANGESTART
)
)
VAR _COUNT =
COUNTAX ( _STATUSLIST, [status] )
RETURN
IF ( _COUNT = 1 && "CLUB" IN _STATUSLIST, "CLUB", "VIP" )
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I did that :
Hi @bapt69 ,
Here I suggest you to create an unrelated calendar table to help you calculate the status.
Data model:
Measure:
Status_Type =
VAR _RANGESTART =
MIN ( 'Calendar'[Date] )
VAR _RANGEEND =
MAX ( 'Calendar'[Date] )
VAR _STATUSLIST =
CALCULATETABLE (
VALUES ( d_client_histo[status] ),
FILTER (
ALLEXCEPT ( d_client_histo, d_client_histo[client_id] ),
d_client_histo[start_date] <= _RANGEEND
&& d_client_histo[end_date] >= _RANGESTART
)
)
VAR _COUNT =
COUNTAX ( _STATUSLIST, [status] )
RETURN
IF ( _COUNT = 1 && "CLUB" IN _STATUSLIST, "CLUB", "VIP" )
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Alright,
First of all, thank you for your answer!
I customize your DAX with my fields :
User | Count |
---|---|
25 | |
10 | |
8 | |
7 | |
6 |
User | Count |
---|---|
32 | |
12 | |
10 | |
10 | |
9 |