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 dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi
I have a few measures, say M1, M2, M3, which depend on year and month (I already have a date dimension table). Because most of visuals for BSC dashboard and reports, and most of KPI visuals which are suitable for my case, expect measures names to be values in table columns (not single measures), I need to create table like this (from the above measures):
Year | Month | Measure name | Measure value |
2020 | 1 | Measure 1 | 12 |
2020 | 1 | Measure 2 | 56.6 |
2020 | 1 | Measure 3 | 1.3 |
... | ... | ... | ... |
And so on. Now my question is: How can I create a table in the above format from measures which are already mentioned? I know that I MAY be able to do this using Power Query, but there are two problems: First, writing complex calculations for goals, targets and indices in strategy area using Power Query is not as simple as DAX; And second, when I write measures using DAX, I can't use them back in Power Query to create such a table (provided creating such a table in Power Query is possible at all, which I'm not sure about).
Thanks in advance.
Solved! Go to Solution.
Hi @SajjadMousavi
You can start with creating a crossjoin table between Measure Names and the values of Year-Month column of the date table. Something like
Filter Table =
CROSSJOIN ( VALUES ( 'Date'[YearMonth] ), { "Measure 1", "Measure 2", "Measure 3" } )
Then create a relationship between the Year-Month columns in the two tables (many to many). The values column that contains the names of the measures can then be used in the table visual without generating error message about the relationship.
Next is simple. Create one measure wich contains switch statement. Something like
Measure =
VAR SelectedMeasure = SELECTEDVALUE ( 'Filter Table'[Value] )
RETURN
SWITCH (
TRUE ( ),
SelectedMeasure = "Measure 1", [Measure 1],
SelectedMeasure = "Measure 2", [Measure 2],
SelectedMeasure = "Measure 3", [Measure 3]
)
Hi @SajjadMousavi
You can start with creating a crossjoin table between Measure Names and the values of Year-Month column of the date table. Something like
Filter Table =
CROSSJOIN ( VALUES ( 'Date'[YearMonth] ), { "Measure 1", "Measure 2", "Measure 3" } )
Then create a relationship between the Year-Month columns in the two tables (many to many). The values column that contains the names of the measures can then be used in the table visual without generating error message about the relationship.
Next is simple. Create one measure wich contains switch statement. Something like
Measure =
VAR SelectedMeasure = SELECTEDVALUE ( 'Filter Table'[Value] )
RETURN
SWITCH (
TRUE ( ),
SelectedMeasure = "Measure 1", [Measure 1],
SelectedMeasure = "Measure 2", [Measure 2],
SelectedMeasure = "Measure 3", [Measure 3]
)
Thanks a lot for your solution. It worked flawlessly! It just needed a small correction in my case (and I don't know why!):
User | Count |
---|---|
14 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
22 | |
11 | |
10 | |
10 | |
8 |