简体   繁体   中英

Dynamic filters - Power BI

I have the below dataset:

在此处输入图片说明

I need to calculate the number of accounts grouped by the datedif between today and first date per an account when type = 'cash'.

If I find the min date per account and type 'cash' using

first date = 
CALCULATE (
    MIN ( tbl[date] ),
    ALLEXCEPT ( tbl, tbl[account] ),tbl[type]="cash")

, I get:

在此处输入图片说明

And then, applying datedif to find the difference between today() and first date, I get:

在此处输入图片说明

The requirement, however, is not to hard-code the type. However, if I use the below formula:

first date = 
CALCULATE (
    MIN ( tbl[date] ),
    ALLEXCEPT ( tbl, tbl[account] ))

and then, 'cash' as a filter, I get the below result which is incorrect:

在此处输入图片说明

Hope this helps..

  1. Change [Account] data type to Text.

  2. First Date = CALCULATE(MIN('Table'[Date]), ALLEXCEPT('Table', 'Table'[Account], 'Table'[Type]))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM