Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi guys,
I have an issue with a calculation in Power BI. Probably this is easier than I can think, but I'm struggling with that.
I need to calculate the Sum(Total Sales) by days filtered in a Slicer. I also need to filter by city and country where the sale was sold.
I created this Measure, but I want to calculate for different cities to show in a Matrix:
Country | City | AT |
US | Miami | [AT US] |
ES | Madrid | [AT EU] |
ES | Barcelona | [AT EU] |
Thank you for your sugestion Sahir_Maharaj,
But didn't work yet. I did what you suggested, but column [AT] shows the value 1 or 0 for each row.
When I did the formula test1, the Sum(Total Sales) was divided by 1 or 0, and not the sum of days which I set on the Slicer.
This will calculate the sum of total sales for the city "Miami" and also consider the value of [AT] for the country. You can repeat the same steps for other cities as well.
Hope this helps! 🙂
2. Use the calculated column in your measure:
teste1 =
CALCULATE(
SUM('Sales'[Total Sales]),
'Sales'[City] = "Miami",
'Sales'[AT]
)
Here's how you can do it:
1. Create a calculated column with the following formula:
AT =
IF('Sales'[Country] = "US", [AT US],
IF('Sales'[Country] = "ES", [AT EU],
[AT]))
You can create a calculated column to store the [AT] value based on the country and then use the calculated column in the measure.
User | Count |
---|---|
77 | |
75 | |
46 | |
31 | |
28 |
User | Count |
---|---|
99 | |
93 | |
50 | |
49 | |
46 |