Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi friends,
I have a table (visual) that can have a variable amount of columns - depending on the filter the user applied. I would like to create a measure which is 40*"number of current columns in the visual".
Can you help?
Solved! Go to Solution.
Hi @campelliann
Create a date table and create a relationship with your main table.
Date =
ADDCOLUMNS (
CALENDARAUTO (),
"year", YEAR ( [Date] ),
"month", MONTH ( [Date] ),
"week", WEEKNUM ( [Date], 2 ),
"year-week", YEAR ( [Date] ) & "-" & "week"
& WEEKNUM ( [Date], 2 )
)
Use the [week] from the date table into a slicer.
Then create measures
actual registered = SUM('Table'[registerd hour])
discount weeks = CALCULATE(DISTINCTCOUNT('Date'[year-week]),ALLSELECTED('Date'))
still need = DISTINCTCOUNT('Table'[name id])*40*[discount weeks]-SUMX('Table',[actual registered])
download my pbix file for more details.
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@v-juanli-msft Maggie, @amitchandak , Thanks in advance for your help.
This is basically a timesheet control to assure everyone registers 40h per week. I select a week (e.g. 5 june) and calculate a measure for the hours yet to be registered - graph at the right. I want the formula to be Hours missing = Number of people x 40 x number of weeks selected - total hours registered in the week/weeks selected
If I select the week 5 june alone, or 12 june alone, the formula works. But if I select both weeks (or more) it doesnt - because the measure i created is for 40 hours per person (doesnt take into account the number of weeks/columns in the filter).
Suming up: if the filter is on 1 week, each person must register 40 h. If in two weeks 80 h etc.
Hi @campelliann
Create a date table and create a relationship with your main table.
Date =
ADDCOLUMNS (
CALENDARAUTO (),
"year", YEAR ( [Date] ),
"month", MONTH ( [Date] ),
"week", WEEKNUM ( [Date], 2 ),
"year-week", YEAR ( [Date] ) & "-" & "week"
& WEEKNUM ( [Date], 2 )
)
Use the [week] from the date table into a slicer.
Then create measures
actual registered = SUM('Table'[registerd hour])
discount weeks = CALCULATE(DISTINCTCOUNT('Date'[year-week]),ALLSELECTED('Date'))
still need = DISTINCTCOUNT('Table'[name id])*40*[discount weeks]-SUMX('Table',[actual registered])
download my pbix file for more details.
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Still a newbie here. It was not that hard 🙂
Many thanks!
I think you need to create a new table based on the logic of creating that visual table. Then you countrows of the new table.
What's more, you need to provide more details on your questions.
Hope this is helpfu.
Proud to be a Super User!
@campelliann , Not sure I got it. typically number measures are constant in a visual.
The information you have provided is not making the problem clear to me. Can you please explain with an example.
Appreciate your Kudos.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
93 | |
77 | |
65 | |
53 |
User | Count |
---|---|
147 | |
106 | |
104 | |
87 | |
61 |