Forum Discussion
DAX Formula placed in rows in a matrix
- 5 years ago
This requires a bit of a more advanced solution.
You're correct that you can not put a measure in rows.
What you're trying to create here is essentially a dynamic histogram. At least, the theory is the same, even if it's not a proper histogram.
Have a look at this:
https://community.powerbi.com/t5/Desktop/Dynamic-Histogram-with-Measures/td-p/856240
If you have a discrete set of potential values, this becomes somewhat easier, also, if you're counting things, and counting by 1s then it's also a bit easier.
Step 1)
Create a table that contains your discrete values
There are a few ways you can do this. You can either calculate the table in DAX, or you can load a table of your expected 'bucket' values, or use enter data to create your list of possible values. Pick your poison.
Step 2)
Create a dax formula that counts the number of things, in your case stores that have made 'n' purchases, where 'n' is the content of the 'bucket' field on the table that contains your discrete values.
Then in your matrix, you use your bucket value field from the table you created, and for measures, you add the measure that does the counting, and it should create the visual you want.
Hey Migsmix ,
so in general there are 2 concepts in Power BI.
You can have a calculated column, this new column is calculated when the file is loaded. Then the value is fix and it's another column that you can use.
The second one in a measure. The measure is always calculated during runtime and needs a context. So if you put the stores in a table the fomula "SUM(Sales)" will give you the number per store. If you remove it you will get the total, if you put in the date column it will calculate the sales by date.
So back to your question, do you want a new column with fix values or do you want to calculate it dynamically?
And then the second question why doesn't Power BI let you put it in a matrix? Do you get an error message? A little more information would help here.
- Migsmix5 years agoFrequent Visitor
- selimovd5 years ago
Most Valuable Professional
Hello Migsmix ,
yes because measures cannot be used as rows, as they need rows as a context.
Why do you want to put them as rows? Don't you want the count by "TIPO"?
Or how should the result look like?
If you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.bi- Migsmix5 years agoFrequent Visitor
Hi selimovd ,
I have a lot of stores (Store ID) and i would like to know how many of them bought only 1 time, 2 times and so on. Maybe what i should do is a dax formula? Hope u can help me. I'm attaching my pbi file here PBI EXAMPLE 🙂
Thanks!