I have a table called 1- Invoices report which looks like this:
Currency IND
Revenue
EBF
66.3
BFE
65.2
CAF
54.3
BGE
65.2
CAE
87.5
AED
45.6
I have to calculate Net Revenue. The Net Revenue has to be in USD currency. The conversion rate goes as follows:
Currency IND
USD Conversion (Divide by this value)
EBF
0.505
BFE
2.8832
CAF
2.66
BGE
0.5851
CAE
0.4775
AED
1.5
I have tried using this code for making a Net Revenue Column but it is not giving the right answers:
Net Revenue =
IF(
'1- Invoices report'[Currency IND]="EBF",('1- Invoices report'[Revenue]/0.505),
IF('1- Invoices report'[Currency IND]="BFE",('1- Invoices report'[Revenue]/2.8832),
IF('1- Invoices report'[Currency IND]="CAF",('1- Invoices report'[Revenue]/2.66),
IF('1- Invoices report'[Currency IND]="BGE",('1- Invoices report'[Revenue]/0.5851),
IF('1- Invoices report'[Currency IND]="CAE",('1- Invoices report'[Revenue]/0.4775),
('1- Invoices report'[Revenue]/1.5)
)))))
Please help.
Put your conversion rate into a separate table and Power BI will create a one-to-one relationship on 'Currency IND'. (Note that in general this would be a one-to-many relationship when you have multiple revenues per currency.)
Now you can put 'Currency IND', 'Revenue' and 'USD Conversion' into one table and Power BI will create an implicit measure (sum aggregation) for the revenue.
You can now add your 'Net Revenue' (in USD) with the following measure:
Net Revenue =
SUMX(
'1- Invoices report',
DIVIDE(
'1- Invoices report'[Revenue],
RELATED('Conversion rate'[USD Conversion])
)
)
and the result will look like this:
Related
I want to create measure Invoice Counter that shows number of invoices per customer. This measure must reflect slicer in the page.
If in year slicer is selected year = 2022, measure should reflex this.
Sorry I don't paste my test code here, it was nonsense so far.
Thanks for help.
Your modelling approach is a little awkward: Your table shows an Invoice Counter of 3 for the single invoice 11 in 2022 for "jack", and the sum of Invoice Counter is 14, although there are 6 different invoices only. This is at least confusing ...
Your Invoice counter measure should aggregate invoice like this:
Invoice Counter =
CALCULATE(
COUNT('Table'[invoice]),
ALLEXCEPT('Table', 'Table'[customer])
)
but then you can't filter it by invoice again, because that will undo the above aggregation. Just put customer, year and Invoice Counter in one table and of cause you can filter that table by year, if you like:
I am trying to create two columns for each product, one that reflects current year sales and another that shows prior year sales.
My underlying data already aggregates all sales by year. In this example I have three tables. One that contains the main sales. And the other is just a measure table where I store all my measures related to sales in Denver. So Denver Sales[Sales] is essentially just a measure which filters the 'Main Sales' table for Denver data only. This measure if defined as follows:
Sales = CALCULATE(SUM('Main Sales'[Sales]),
FILTER('Main Sales', 'Main Sales[City] = "Denver")
)
The third table is the Product table, which only contain two columns Product Name and Product ID. It has a relationship with Main Sales based on the Product ID.
So in order to get the PY sales, I tried to create a measure with the following DAX code:
PY Sales =
VAR py_sales =
CALCULATE(
'Denver Sales'[Sales],
FILTER ( ALLSELECTED('Main Sales'), 'Main Sales'[Year] = MAX ( 'Main Sales'[Year]) -1 )
)
RETURN
py_sales
However, as you can see below. The PY Sales column is taking the sum of all 3 products' PY sales for each year, rather than just the individual product.
Can anyone help me understand why my code is doing this?
I am trying to calculate the Cumulative Purchases by YTD. The first step is to rank the items by Cost Amount, but when I try to rank by the [_YTD Cost] measure, the numbers I get do not make sense (skipped numbers, duplicated).
[]
I had 3 slicers: Month, Year and to select Month/YTD measures. Since with the Month calculation I have no problems, I removed the interaction with the Month/YTD slicer and I placed only YTD measures on the table:
Total Purchase Cost = SUM ( Purchases[Amount] )
_YTD Cost = TOTALYTD([Total Purchase Cost], 'dim-calendar'[Date])
_RANK YTD = RANKX(ALLSELECTED(Purchases), [_YTD Cost])
Notes:
I pulled the item from the Item table
The Purchase table is linked to the Date table by Purchase Date
Not 100 % sure on your data model, but try changing your RANKX(ALLSELECTED(***) to reference the Item-column. Like this:
RANKX(ALLSELECTED('Item'[Item]), [_YTD Cost])
Using the Contoso database, I have a report that looks as follows:
The measure for Percent of Total is:
Percent of Total =
VAR SelectedSalesTotal = CALCULATE(
[Sales Amount],
ALLSELECTED(Products[Brand Name]),
ALLSELECTED(Customers[Country])
)
RETURN
DIVIDE([Sales Amount], SelectedSalesTotal)
Now I want to change this so that the percentage for each country is not the percentage based on total sales, but based on brand name sales. So, for example, for the brand A. Datum and Canada, instead of 4.48%, it should be 26.96% (7,011,941.77 / 26,007,534.55). The Percent of Total values for each brand shouldn't change. So, A. Datum should remain at 16.62%.
I have been unable to figure out how to do this.
The data model looks like this:
Create a measure to compare forecast vs sales in power BI.
The logic is that at the beginning of Jan. 2018 it is forecasted the sales for the whole year and the amount of pcs sold in Jan. 2018 is only known in Feb. 2018 (next month's file). As an example, we are in Nov. 2018 and it is known how many pcs were sold in the previous months. I want to create a table to compare forecast vs sales.
My dataset looks like the figure below. It is marked in red the historical data.
An example of a power BI matrix that I am trying to create by dividing forecast by sales
It looks like you need to normalize your data source. This may look something like:
Now you can create some measures. Create a Forecast Qty measure:
Forecast Qty:=CALCULATE (
SUM ( SourceTable[Qty] ),
SourceTable[Type] = "Forecast"
)
A Sold Qty measure:
Sold Qty:=CALCULATE (
SUM ( SourceTable[Qty] ),
SourceTable[Type] = "Sold"
)
And a Sales % Forecast Measure:
Sales % Forecast:=DIVIDE (
[Sold Qty],
[Forecast Qty],
BLANK()
)
Now you can lay out your visualisation as you choose. For example: