cancel
Showing results for
Did you mean:
Helper V

## count customers with digital transaction ratio bigger than in a date period

i have this table

 customer date transaction type amount 1 1/1/2022 digital 10 1 1/2/2022 digital 20 1 1/3/2022 digital 30 1 1/4/2022 digital 11 1 1/5/2022 digital 48 1 1/6/2022 digital 69 1 1/1/2022 physical 45 1 1/2/2022 physical 85 1 1/3/2022 physical 96 1 1/4/2022 physical 47 1 1/5/2022 physical 6 1 1/6/2022 physical 22 2 1/1/2022 digital 10 2 1/2/2022 digital 20 2 1/3/2022 digital 30 2 1/4/2022 digital 11 2 1/5/2022 digital 48 2 1/6/2022 digital 69 2 1/1/2022 physical 45 2 1/2/2022 physical 85 2 1/3/2022 physical 96 2 1/4/2022 physical 47 2 1/5/2022 physical 6 2 1/6/2022 physical 22 2 1/1/2022 digital 10 2 1/2/2022 digital 20 2 1/3/2022 digital 30 2 1/4/2022 digital 11 2 1/5/2022 digital 48 2 1/6/2022 digital 69 2 1/1/2022 physical 45 2 1/2/2022 physical 85 2 1/3/2022 physical 96 2 1/4/2022 physical 47 2 1/5/2022 physical 6 2 1/6/2022 physical 22

for each customer i want to calculate the ratio digital / total transactions (digital+physical) amount in the last 3 months

a customers that has ratio >0.5 (digital transactions more than 50% of his total transactions is a digital customer

I want when selecting a month form a slicer (example 01/06/2022) to count the customers of this month that have a >0.5 in the last 3 months of this selection.

2 ACCEPTED SOLUTIONS
Super User

 Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! DAX is simple, but NOT EASY!
Super User
``````=
COUNTROWS(
FILTER(
VALUES( TXN[customer] ),
CALCULATE(
CALCULATE( [Total], TXN[transaction type] = "digital" ) / [Total],
DATESINPERIOD( DATES[Date], MAX( DATES[Date] ), -3, MONTH )
) > .5
)
)``````

 Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! DAX is simple, but NOT EASY!
6 REPLIES 6
Helper V

can the dax be modified so it shows in a card the distinct count of customers for this? (>0.5)?

Super User

To obtain the same visual effect as Card,

 Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! DAX is simple, but NOT EASY!
Helper V

I would like to count the customers. Example 4 customers in this month had digital ratio (3 month  transactions) >0.5

Super User
``````=
COUNTROWS(
FILTER(
VALUES( TXN[customer] ),
CALCULATE(
CALCULATE( [Total], TXN[transaction type] = "digital" ) / [Total],
DATESINPERIOD( DATES[Date], MAX( DATES[Date] ), -3, MONTH )
) > .5
)
)``````

 Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! DAX is simple, but NOT EASY!
Helper V

Thanks worked great!

Super User

 Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! DAX is simple, but NOT EASY!

Announcements

#### Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

#### Power BI March 2023 Update

Find out more about the March 2023 update.

#### March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors
Top Kudoed Authors