The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a visual like this:
Date | convert_number |
Dec | 5 |
Jan | 22 |
Feb | 12 |
convert_number is a measure that counts customers based on conditions
I have two other measures that calculates the average sales before event, and the average sales after.
I would like to count how many customers of convert_number have increased average sales.
e.g. countif(sales after - sales before) > 0
Obviously this doesn't work, I tried using count and countA but they need tables, could someone come up with a solution so my visual would be like this:
Date | convert_number | increased sales |
Dec | 5 | 3 |
Jan | 22 | 17 |
Feb | 12 | 9 |
Thanks a lot!
Solved! Go to Solution.
@Anonymous
Try this code
increased sale =
VAR T1 =
SUMMARIZE ( ALL ( 'Orders' ), 'Date'[Date] )
VAR T2 =
ADDCOLUMNS (
T1,
"@Count", [convert_number],
"@SalesBefore", [Sales Before],
"@SalesAfter", [Sales After]
)
VAR T3 =
FILTER ( T2, [@SalesAfter] > [@SalesBefore] )
RETURN
SUMX ( T3, [@Count] )
@Anonymous
Try this code
increased sale =
VAR T1 =
SUMMARIZE ( ALL ( 'Orders' ), 'Date'[Date] )
VAR T2 =
ADDCOLUMNS (
T1,
"@Count", [convert_number],
"@SalesBefore", [Sales Before],
"@SalesAfter", [Sales After]
)
VAR T3 =
FILTER ( T2, [@SalesAfter] > [@SalesBefore] )
RETURN
SUMX ( T3, [@Count] )
Hi @Anonymous
What are the tables invloved? Do you have a Date table? you are slicing by Month right? From which table?
However, you may try somthing like this
increased sale =
SUMX ( VALUES ( 'Date'[Date] ), IF ( [Sales After] > [Sales Before], 1 ) )
Thank you for the response!
Only the order table is involved. I have a date table. I am slicing it by month from the date table.
I tried the solution but it returns a static number that's the same for every month.
Hi, @Anonymous
Could you please tell me whether your problem has been solved?
If yes, you could accept the helpful answer as solution.
If you still need help, please share a sample file for further research
Best Regards,
Community Support Team _ Eason
Noted
can you please provide the code of the three Measures?